Explanation sought for some datalib functions

Explanation sought for some datalib functions

by John Kilbride -
Number of replies: 3
I'm trying to interact with the logs with the end intention of tracking user progress etc.
Has anyone tried using the log funtions:
  1. get_logs ($select, $order, $limitfrom, $limitnum, &$totalcount)
  2. get_logs_usercourse($userid, $courseid, $coursestart)
  3. get_logs_userday($userid, $courseid, $daystart)
If so, can you explain what $select should look like in funtion 1 and what effects the parameters $limitfrom and $limitnum have.
Also the $courseStart in funcion 2, is this the date the course started?
and in 3 is daystart the log report generated from daystart and ending daystart +24hrs?

Finally do these methods return arrays of course log/access statistics?
Average of ratings: -
In reply to John Kilbride

Re: Explanation sought for some datalib functions

by Penny Leach -
$select is the WHERE part of the sql query - which ends up looking like

SELECT fields FROM tables WHERE $select

so the $select part needs to be from options (example: in course/log.php I believe it's built up from the drop down menus at the top)

$limitfrom and $limitnum are the number of results you want. For example, with paginated results, if you were on page 2 and you were showing 20 per page, $limitfrom would be 10 and $limitnum would be 20.

I don't know the answer about daystart and coursestart

I believe they return arrays of objects with fields corresponding to database columns.

So, for example, there's a column in the log table called userid, so you'd have

$logrecord->userid

try $logs = get_logs($arguments,$go,$here);
print_r($logs);

to see exactly what you get back.

Hope that helps
Penny
In reply to Penny Leach

Re: Explanation sought for some datalib functions

by John Kilbride -

Thanks problem solved. I edited the moodle code in get_logs to print out the arguments so i could see how the $select string worked. I suspected it was either the select or where part of the sql query.

In case this helps anyone later $select should look like this:

l.userid = '1' AND l.time > '1097449200' AND l.time < '1097535600'

I figured out the strings i needed by editing the get_logs method in datalib.php to print the arguments it was passed and then using the logs page, and inspecting the strings it was generating.

Thanks

JK