NOBUG DB syntax - fix/improve some uses. I haven't tested completion, have you?
This commit is contained in:
@@ -43,7 +43,7 @@ $course = $DB->get_record('course', array('id' => $id));
|
||||
|
||||
// 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 {
|
||||
|
||||
@@ -403,7 +403,7 @@ if(!$csv) {
|
||||
|
||||
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;
|
||||
|
||||
+5
-5
@@ -363,12 +363,12 @@ switch ($mode) {
|
||||
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}
|
||||
";
|
||||
@@ -395,7 +395,7 @@ switch ($mode) {
|
||||
}
|
||||
|
||||
// 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');
|
||||
@@ -459,7 +459,7 @@ switch ($mode) {
|
||||
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
|
||||
|
||||
@@ -347,8 +347,8 @@ abstract class grade_report {
|
||||
$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) {
|
||||
|
||||
@@ -93,8 +93,9 @@ class completion_criteria_course extends completion_criteria {
|
||||
* @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
|
||||
@@ -125,7 +126,9 @@ class completion_criteria_course extends completion_criteria {
|
||||
* @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));
|
||||
}
|
||||
|
||||
@@ -199,14 +202,14 @@ class completion_criteria_course extends completion_criteria {
|
||||
* @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();
|
||||
|
||||
@@ -353,8 +353,8 @@
|
||||
'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
|
||||
|
||||
@@ -76,7 +76,7 @@ function xmldb_workshop_upgrade($oldversion) {
|
||||
'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
|
||||
|
||||
Reference in New Issue
Block a user