MDL-55175 course: Begin deprecation process for pring_log_*
This commit is contained in:
-110
@@ -1671,116 +1671,6 @@ function user_accesstime_log($courseid=0) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all log records based on SQL criteria
|
||||
*
|
||||
* @package core
|
||||
* @category log
|
||||
* @global moodle_database $DB
|
||||
* @param string $select SQL select criteria
|
||||
* @param array $params named sql type params
|
||||
* @param string $order SQL order by clause to sort the records returned
|
||||
* @param string $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set)
|
||||
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set)
|
||||
* @param int $totalcount Passed in by reference.
|
||||
* @return array
|
||||
*/
|
||||
function get_logs($select, array $params=null, $order='l.time DESC', $limitfrom='', $limitnum='', &$totalcount) {
|
||||
global $DB;
|
||||
|
||||
if ($order) {
|
||||
$order = "ORDER BY $order";
|
||||
}
|
||||
|
||||
$selectsql = "";
|
||||
$countsql = "";
|
||||
|
||||
if ($select) {
|
||||
$select = "WHERE $select";
|
||||
}
|
||||
|
||||
$sql = "SELECT COUNT(*)
|
||||
FROM {log} l
|
||||
$select";
|
||||
|
||||
$totalcount = $DB->count_records_sql($sql, $params);
|
||||
$allnames = get_all_user_name_fields(true, 'u');
|
||||
$sql = "SELECT l.*, $allnames, u.picture
|
||||
FROM {log} l
|
||||
LEFT JOIN {user} u ON l.userid = u.id
|
||||
$select
|
||||
$order";
|
||||
|
||||
return $DB->get_records_sql($sql, $params, $limitfrom, $limitnum) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Select all log records for a given course and user
|
||||
*
|
||||
* @package core
|
||||
* @category log
|
||||
* @global moodle_database $DB
|
||||
* @uses DAYSECS
|
||||
* @param int $userid The id of the user as found in the 'user' table.
|
||||
* @param int $courseid The id of the course as found in the 'course' table.
|
||||
* @param string $coursestart unix timestamp representing course start date and time.
|
||||
* @return array
|
||||
*/
|
||||
function get_logs_usercourse($userid, $courseid, $coursestart) {
|
||||
global $DB;
|
||||
|
||||
$params = array();
|
||||
|
||||
$courseselect = '';
|
||||
if ($courseid) {
|
||||
$courseselect = "AND course = :courseid";
|
||||
$params['courseid'] = $courseid;
|
||||
}
|
||||
$params['userid'] = $userid;
|
||||
// We have to sanitize this param ourselves here instead of relying on DB.
|
||||
// Postgres complains if you use name parameter or column alias in GROUP BY.
|
||||
// See MDL-27696 and 51c3e85 for details.
|
||||
$coursestart = (int)$coursestart;
|
||||
|
||||
return $DB->get_records_sql("SELECT FLOOR((time - $coursestart)/". DAYSECS .") AS day, COUNT(*) AS num
|
||||
FROM {log}
|
||||
WHERE userid = :userid
|
||||
AND time > $coursestart $courseselect
|
||||
GROUP BY FLOOR((time - $coursestart)/". DAYSECS .")", $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all log records for a given course, user, and day
|
||||
*
|
||||
* @package core
|
||||
* @category log
|
||||
* @global moodle_database $DB
|
||||
* @uses HOURSECS
|
||||
* @param int $userid The id of the user as found in the 'user' table.
|
||||
* @param int $courseid The id of the course as found in the 'course' table.
|
||||
* @param string $daystart unix timestamp of the start of the day for which the logs needs to be retrived
|
||||
* @return array
|
||||
*/
|
||||
function get_logs_userday($userid, $courseid, $daystart) {
|
||||
global $DB;
|
||||
|
||||
$params = array('userid'=>$userid);
|
||||
|
||||
$courseselect = '';
|
||||
if ($courseid) {
|
||||
$courseselect = "AND course = :courseid";
|
||||
$params['courseid'] = $courseid;
|
||||
}
|
||||
$daystart = (int)$daystart; // note: unfortunately pg complains if you use name parameter or column alias in GROUP BY
|
||||
|
||||
return $DB->get_records_sql("SELECT FLOOR((time - $daystart)/". HOURSECS .") AS hour, COUNT(*) AS num
|
||||
FROM {log}
|
||||
WHERE userid = :userid
|
||||
AND time > $daystart $courseselect
|
||||
GROUP BY FLOOR((time - $daystart)/". HOURSECS .") ", $params);
|
||||
}
|
||||
|
||||
/// GENERAL HELPFUL THINGS ///////////////////////////////////
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user