// Load user
if ($userid) {
- if (!$user = get_record('user', 'id', $userid)) {
+ if (!$user = $DB->get_record('user', array('id' => $userid))) {
error('User ID incorrect');
}
} else {
case COMPLETION_CRITERIA_TYPE_COURSE:
// Load course
- $crs = get_record('course', 'id', $criterion->courseinstance);
+ $crs = $DB->get_record('course', array('id' => $criterion->courseinstance));
// Display icon
$iconlink = $CFG->wwwroot.'/course/view.php?id='.$criterion->courseinstance;
SELECT DISTINCT
c.id AS id
FROM
- {$CFG->prefix}course c
+ {course} c
INNER JOIN
- {$CFG->prefix}context con
+ {context} con
ON con.instanceid = c.id
INNER JOIN
- {$CFG->prefix}role_assignments ra
+ {role_assignments} ra
ON ra.contextid = con.id
AND ra.userid = {$user->id}
";
}
// Check if result is empty
- if (!$rs = get_recordset_sql($sql)) {
+ if (!$rs = $DB->get_recordset_sql($sql)) {
if ($course->id != 1) {
$error = get_string('nocompletions', 'coursereport_completion');
foreach ($infos as $c_info) {
// Get course info
- $c_course = get_record('course', 'id', $c_info->course_id);
+ $c_course = $DB->get_record('course', array('id' => $c_info->course_id));
$course_name = $c_course->fullname;
// Get completions
$items = grade_item::fetch_all(array('courseid'=>$courseid));
$grades = array();
$sql = "SELECT g.*
- FROM {$CFG->prefix}grade_grades g
- JOIN {$CFG->prefix}grade_items gi ON gi.id = g.itemid
+ FROM {grade_grades} g
+ JOIN {grade_items} gi ON gi.id = g.itemid
WHERE g.userid = {$this->user->id} AND gi.courseid = {$courseid}";
if ($gradesrecords = $DB->get_records_sql($sql)) {
foreach ($gradesrecords as $grade) {
* @return boolean
*/
public function review($completion, $mark = true) {
+ global $DB;
- $course = get_record('course', 'id', $this->courseinstance);
+ $course = $DB->get_record('course', array('id' => $this->courseinstance));
$info = new completion_info($course);
// If the course is complete
* @return string
*/
public function get_title_detailed() {
- $prereq = get_record('course', 'id', $this->courseinstance);
+ global $DB;
+
+ $prereq = $DB->get_record('course', array('id' => $this->courseinstance));
return shorten_text(urldecode($prereq->fullname));
}
* @return array
*/
public function get_details($completion) {
- global $CFG;
+ global $CFG, $DB;
// Get completion info
$course = new object();
$course->id = $completion->course;
$info = new completion_info($course);
- $prereq = get_record('course', 'id', $this->courseinstance);
+ $prereq = $DB->get_record('course', array('id' => $this->courseinstance));
$prereq_info = new completion_info($prereq);
$details = array();
'u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, u.imagealt, u.email ';
// This part is the same for all cases - join users and scorm_scoes_track tables
- $from = 'FROM '.$CFG->prefix.'user u ';
- $from .= 'LEFT JOIN '.$CFG->prefix.'scorm_scoes_track st ON st.userid = u.id AND st.scormid = '.$scorm->id;
+ $from = 'FROM {user} u ';
+ $from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = '.$scorm->id;
switch ($attemptsmode){
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH:
// Show only students with attempts
'workshop_grades', 'workshop_comments', 'workshop_stockcomments') as $tableorig) {
$tablearchive = $tableorig . '_old';
if ($dbman->table_exists($tableorig)) {
- $dbman->rename_table(new XMLDBTable($tableorig), $tablearchive);
+ $dbman->rename_table(new xmldb_table($tableorig), $tablearchive);
}
// append a new field 'newplugin' into every archived table. In this field, the name of the subplugin
// who adopted the record during the migration is stored. null value means the record is not migrated yet