Skip to content

Commit

Permalink
NOBUG DB syntax - fix/improve some uses. I haven't tested completion,…
Browse files Browse the repository at this point in the history
… have you?
  • Loading branch information
stronk7 committed Jul 5, 2010
1 parent c83d9e1 commit ffe5025
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion blocks/completionstatus/details.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

// 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 {
Expand Down
2 changes: 1 addition & 1 deletion course/report/completion/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ function csv_quote($value) {

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;
Expand Down
10 changes: 5 additions & 5 deletions course/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,12 @@
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}
";
Expand All @@ -395,7 +395,7 @@
}

// 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');
Expand Down Expand Up @@ -459,7 +459,7 @@
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
Expand Down
4 changes: 2 additions & 2 deletions grade/report/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ protected function blank_hidden_total($courseid, $course_item, $finalgrade) {
$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) {
Expand Down
11 changes: 7 additions & 4 deletions lib/completion/completion_criteria_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public function update_config(&$data) {
* @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
Expand Down Expand Up @@ -125,7 +126,9 @@ public function get_title() {
* @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));
}

Expand Down Expand Up @@ -199,14 +202,14 @@ public function cron() {
* @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();
Expand Down
4 changes: 2 additions & 2 deletions mod/scorm/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mod/workshop/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ffe5025

Please sign in to comment.