Merge branch 'MDL-25708' of git://github.com/stronk7/moodle

This commit is contained in:
Petr Skoda 2011-01-31 14:21:53 +01:00
commit 8afc38bd39
53 changed files with 514 additions and 526 deletions

View file

@ -49,10 +49,10 @@ function xmldb_assignment_upgrade($oldversion) {
$count = $DB->count_records_sql("SELECT COUNT('x') $sqlfrom");
if ($rs = $DB->get_recordset_sql("SELECT s.id, s.userid, s.teacher, s.assignment, a.course, cm.id AS cmid $sqlfrom ORDER BY a.course, s.assignment")) {
$rs = $DB->get_recordset_sql("SELECT s.id, s.userid, s.teacher, s.assignment, a.course, cm.id AS cmid $sqlfrom ORDER BY a.course, s.assignment");
if ($rs->valid()) {
$pbar = new progress_bar('migrateassignmentfiles', 500, true);
$i = 0;
foreach ($rs as $submission) {
$i++;
@ -122,9 +122,8 @@ function xmldb_assignment_upgrade($oldversion) {
@rmdir("$CFG->dataroot/$submission->course/$CFG->moddata/assignment/$submission->assignment");
@rmdir("$CFG->dataroot/$submission->course/$CFG->moddata/assignment");
}
$rs->close();
}
$rs->close();
upgrade_mod_savepoint(true, 2008081900, 'assignment');
}

View file

@ -2688,7 +2688,8 @@ function assignment_upgrade_grades() {
$sql = "SELECT a.*, cm.idnumber AS cmidnumber, a.course AS courseid
FROM {assignment} a, {course_modules} cm, {modules} m
WHERE m.name='assignment' AND m.id=cm.module AND cm.instance=a.id";
if ($rs = $DB->get_recordset_sql($sql)) {
$rs = $DB->get_recordset_sql($sql);
if ($rs->valid()) {
// too much debug output
$pbar = new progress_bar('assignmentupgradegrades', 500, true);
$i=0;
@ -2698,9 +2699,9 @@ function assignment_upgrade_grades() {
assignment_update_grades($assignment);
$pbar->update($i, $count, "Updating Assignment grades ($i/$count).");
}
$rs->close();
upgrade_set_timeout(); // reset to default timeout
}
$rs->close();
}
/**

View file

@ -55,16 +55,16 @@ function xmldb_data_upgrade($oldversion) {
}
if ($oldversion < 2008081400) {
if ($rs = $DB->get_recordset('data')) {
$pattern = '/\#\#delete\#\#(\s+)\#\#approve\#\#/';
$replacement = '##delete##$1##approve##$1##export##';
foreach ($rs as $data) {
$data->listtemplate = preg_replace($pattern, $replacement, $data->listtemplate);
$data->singletemplate = preg_replace($pattern, $replacement, $data->singletemplate);
$DB->update_record('data', $data);
}
$rs->close();
$pattern = '/\#\#delete\#\#(\s+)\#\#approve\#\#/';
$replacement = '##delete##$1##approve##$1##export##';
$rs = $DB->get_recordset('data');
foreach ($rs as $data) {
$data->listtemplate = preg_replace($pattern, $replacement, $data->listtemplate);
$data->singletemplate = preg_replace($pattern, $replacement, $data->singletemplate);
$DB->update_record('data', $data);
}
$rs->close();
upgrade_mod_savepoint(true, 2008081400, 'data');
}
@ -89,8 +89,9 @@ function xmldb_data_upgrade($oldversion) {
$count = $DB->count_records_sql("SELECT COUNT('x') $sqlfrom");
if ($rs = $DB->get_recordset_sql("SELECT c.id, f.type, r.dataid, c.recordid, f.id AS fieldid, r.userid, c.content, c.content1, d.course, r.userid, cm.id AS cmid $sqlfrom ORDER BY d.course, d.id")) {
$rs = $DB->get_recordset_sql("SELECT c.id, f.type, r.dataid, c.recordid, f.id AS fieldid, r.userid, c.content, c.content1, d.course, r.userid, cm.id AS cmid $sqlfrom ORDER BY d.course, d.id");
if ($rs->valid()) {
$pbar = new progress_bar('migratedatafiles', 500, true);
$i = 0;
@ -142,8 +143,9 @@ function xmldb_data_upgrade($oldversion) {
@rmdir("$CFG->dataroot/$content->course/$CFG->moddata/data");
@rmdir("$CFG->dataroot/$content->course/$CFG->moddata");
}
$rs->close();
}
$rs->close();
upgrade_mod_savepoint(true, 2008091400, 'data');
}
@ -218,31 +220,31 @@ function xmldb_data_upgrade($oldversion) {
$lastdataid = null;
$lastcourseid = null;
$modcontext = null;
if ($rs = $DB->get_recordset_sql($sql)) {
foreach($rs as $res) {
if ($res->dataid != $lastdataid || $res->courseid != $lastcourseid) {
$cm = get_coursemodule_from_instance('data', $res->dataid, $res->courseid);
if ($cm) {
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
}
$lastdataid = $res->dataid;
$lastcourseid = $res->courseid;
}
$cmt = new stdClass();
$cmt->contextid = $modcontext->id;
$cmt->commentarea = 'database_entry';
$cmt->itemid = $res->itemid;
$cmt->content = $res->commentcontent;
$cmt->format = $res->format;
$cmt->userid = $res->userid;
$cmt->timecreated = $res->timecreated;
// comments class will throw an exception if error occurs
$cmt_id = $DB->insert_record('comments', $cmt);
if (!empty($cmt_id)) {
$DB->delete_records('data_comments', array('id'=>$res->commentid));
$rs = $DB->get_recordset_sql($sql);
foreach($rs as $res) {
if ($res->dataid != $lastdataid || $res->courseid != $lastcourseid) {
$cm = get_coursemodule_from_instance('data', $res->dataid, $res->courseid);
if ($cm) {
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
}
$lastdataid = $res->dataid;
$lastcourseid = $res->courseid;
}
$cmt = new stdClass();
$cmt->contextid = $modcontext->id;
$cmt->commentarea = 'database_entry';
$cmt->itemid = $res->itemid;
$cmt->content = $res->commentcontent;
$cmt->format = $res->format;
$cmt->userid = $res->userid;
$cmt->timecreated = $res->timecreated;
// comments class will throw an exception if error occurs
$cmt_id = $DB->insert_record('comments', $cmt);
if (!empty($cmt_id)) {
$DB->delete_records('data_comments', array('id'=>$res->commentid));
}
}
$rs->close();
// the default exception handler will stop the script if error occurs before
$dbman->drop_table($table);
}

View file

@ -361,13 +361,14 @@ class data_field_base { // Base class for Database Field Types (see field/*/
$conditions = array('fieldid'=>$this->field->id);
}
if ($rs = $DB->get_recordset('data_content', $conditions)) {
$rs = $DB->get_recordset('data_content', $conditions);
if ($rs->valid()) {
$fs = get_file_storage();
foreach ($rs as $content) {
$fs->delete_area_files($this->context->id, 'mod_data', 'content', $content->id);
}
$rs->close();
}
$rs->close();
return $DB->delete_records('data_content', $conditions);
}
@ -1071,7 +1072,8 @@ function data_upgrade_grades() {
$sql = "SELECT d.*, cm.idnumber AS cmidnumber, d.course AS courseid
FROM {data} d, {course_modules} cm, {modules} m
WHERE m.name='data' AND m.id=cm.module AND cm.instance=d.id";
if ($rs = $DB->get_recordset_sql($sql)) {
$rs = $DB->get_recordset_sql($sql);
if ($rs->valid()) {
// too much debug output
$pbar = new progress_bar('dataupgradegrades', 500, true);
$i=0;
@ -1081,8 +1083,8 @@ function data_upgrade_grades() {
data_update_grades($data, 0, false);
$pbar->update($i, $count, "Updating Database grades ($i/$count).");
}
$rs->close();
}
$rs->close();
}
/**
@ -2448,39 +2450,38 @@ function data_reset_userdata($data) {
$course_context = get_context_instance(CONTEXT_COURSE, $data->courseid);
$notenrolled = array();
$fields = array();
if ($rs = $DB->get_recordset_sql($recordssql, array($data->courseid))) {
foreach ($rs as $record) {
if (array_key_exists($record->userid, $notenrolled) or !$record->userexists or $record->userdeleted
or !is_enrolled($course_context, $record->userid)) {
//delete ratings
if (!$cm = get_coursemodule_from_instance('data', $record->dataid)) {
continue;
}
$datacontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$ratingdeloptions->contextid = $datacontext->id;
$ratingdeloptions->itemid = $record->id;
$rm->delete_ratings($ratingdeloptions);
$DB->delete_records('comments', array('itemid'=>$record->id, 'commentarea'=>'database_entry'));
$DB->delete_records('data_content', array('recordid'=>$record->id));
$DB->delete_records('data_records', array('id'=>$record->id));
// HACK: this is ugly - the recordid should be before the fieldid!
if (!array_key_exists($record->dataid, $fields)) {
if ($fs = $DB->get_records('data_fields', array('dataid'=>$record->dataid))) {
$fields[$record->dataid] = array_keys($fs);
} else {
$fields[$record->dataid] = array();
}
}
foreach($fields[$record->dataid] as $fieldid) {
fulldelete("$CFG->dataroot/$data->courseid/moddata/data/$record->dataid/$fieldid/$record->id");
}
$notenrolled[$record->userid] = true;
$rs = $DB->get_recordset_sql($recordssql, array($data->courseid));
foreach ($rs as $record) {
if (array_key_exists($record->userid, $notenrolled) or !$record->userexists or $record->userdeleted
or !is_enrolled($course_context, $record->userid)) {
//delete ratings
if (!$cm = get_coursemodule_from_instance('data', $record->dataid)) {
continue;
}
$datacontext = get_context_instance(CONTEXT_MODULE, $cm->id);
$ratingdeloptions->contextid = $datacontext->id;
$ratingdeloptions->itemid = $record->id;
$rm->delete_ratings($ratingdeloptions);
$DB->delete_records('comments', array('itemid'=>$record->id, 'commentarea'=>'database_entry'));
$DB->delete_records('data_content', array('recordid'=>$record->id));
$DB->delete_records('data_records', array('id'=>$record->id));
// HACK: this is ugly - the recordid should be before the fieldid!
if (!array_key_exists($record->dataid, $fields)) {
if ($fs = $DB->get_records('data_fields', array('dataid'=>$record->dataid))) {
$fields[$record->dataid] = array_keys($fs);
} else {
$fields[$record->dataid] = array();
}
}
foreach($fields[$record->dataid] as $fieldid) {
fulldelete("$CFG->dataroot/$data->courseid/moddata/data/$record->dataid/$fieldid/$record->id");
}
$notenrolled[$record->userid] = true;
}
$rs->close();
$status[] = array('component'=>$componentstr, 'item'=>get_string('deletenotenrolled', 'data'), 'error'=>false);
}
$rs->close();
$status[] = array('component'=>$componentstr, 'item'=>get_string('deletenotenrolled', 'data'), 'error'=>false);
}
// remove all ratings

View file

@ -48,7 +48,10 @@ function folder_20_migrate() {
return;
}
if (!$candidates = $DB->get_recordset('resource_old', array('type'=>'directory', 'migrated'=>0))) {
$candidates = $DB->get_recordset('resource_old', array('type'=>'directory', 'migrated'=>0));
if (!$candidates->valid()) {
$candidates->close(); // Not going to iterate (but exit), close rs
return;
}
@ -101,4 +104,4 @@ function folder_20_migrate() {
// clear all course modinfo caches
rebuild_course_cache(0, true);
}
}

View file

@ -104,7 +104,8 @@ function xmldb_forum_upgrade($oldversion) {
$count = $DB->count_records_sql("SELECT COUNT('x') $sqlfrom");
if ($rs = $DB->get_recordset_sql("SELECT p.id, p.attachment, p.userid, d.forum, f.course, cm.id AS cmid $sqlfrom ORDER BY f.course, f.id, d.id")) {
$rs = $DB->get_recordset_sql("SELECT p.id, p.attachment, p.userid, d.forum, f.course, cm.id AS cmid $sqlfrom ORDER BY f.course, f.id, d.id");
if ($rs->valid()) {
$pbar = new progress_bar('migrateforumfiles', 500, true);
@ -146,8 +147,8 @@ function xmldb_forum_upgrade($oldversion) {
@rmdir("$CFG->dataroot/$post->course/$CFG->moddata/forum/$post->forum");
@rmdir("$CFG->dataroot/$post->course/$CFG->moddata/forum");
}
$rs->close();
}
$rs->close();
upgrade_mod_savepoint(true, 2008081900, 'forum');
}

View file

@ -1504,7 +1504,8 @@ function forum_upgrade_grades() {
$sql = "SELECT f.*, cm.idnumber AS cmidnumber, f.course AS courseid
FROM {forum} f, {course_modules} cm, {modules} m
WHERE m.name='forum' AND m.id=cm.module AND cm.instance=f.id";
if ($rs = $DB->get_recordset_sql($sql)) {
$rs = $DB->get_recordset_sql($sql);
if ($rs->valid()) {
$pbar = new progress_bar('forumupgradegrades', 500, true);
$i=0;
foreach ($rs as $forum) {
@ -1513,8 +1514,8 @@ function forum_upgrade_grades() {
forum_update_grades($forum, 0, false);
$pbar->update($i, $count, "Updating Forum grades ($i/$count).");
}
$rs->close();
}
$rs->close();
}
/**

View file

@ -45,7 +45,8 @@ function xmldb_glossary_upgrade($oldversion) {
$count = $DB->count_records_sql("SELECT COUNT('x') $sqlfrom");
if ($rs = $DB->get_recordset_sql("SELECT ge.id, ge.userid, ge.attachment, ge.glossaryid, ge.sourceglossaryid, g.course, cm.id AS cmid $sqlfrom ORDER BY g.course, g.id")) {
$rs = $DB->get_recordset_sql("SELECT ge.id, ge.userid, ge.attachment, ge.glossaryid, ge.sourceglossaryid, g.course, cm.id AS cmid $sqlfrom ORDER BY g.course, g.id");
if ($rs->valid()) {
$pbar = new progress_bar('migrateglossaryfiles', 500, true);
@ -92,8 +93,8 @@ function xmldb_glossary_upgrade($oldversion) {
@rmdir("$CFG->dataroot/$entry->course/$CFG->moddata/glossary/$entry->glossaryid");
@rmdir("$CFG->dataroot/$entry->course/$CFG->moddata/glossary");
}
$rs->close();
}
$rs->close();
upgrade_mod_savepoint(true, 2008081900, 'glossary');
}
@ -240,30 +241,30 @@ function xmldb_glossary_upgrade($oldversion) {
$modcontext = null;
/// move glossary comments to comments table
if ($rs = $DB->get_recordset_sql($sql)) {
foreach($rs as $res) {
if ($res->glossaryid != $lastglossaryid || $res->courseid != $lastcourseid) {
$cm = get_coursemodule_from_instance('glossary', $res->glossaryid, $res->courseid);
if ($cm) {
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
}
$lastglossaryid = $res->glossaryid;
$lastcourseid = $res->courseid;
}
$cmt = new stdClass();
$cmt->contextid = $modcontext->id;
$cmt->commentarea = 'glossary_entry';
$cmt->itemid = $res->itemid;
$cmt->content = $res->commentcontent;
$cmt->format = $res->format;
$cmt->userid = $res->userid;
$cmt->timecreated = $res->timemodified;
$cmt_id = $DB->insert_record('comments', $cmt);
if (!empty($cmt_id)) {
$DB->delete_records('glossary_comments', array('id'=>$res->old_id));
$rs = $DB->get_recordset_sql($sql);
foreach($rs as $res) {
if ($res->glossaryid != $lastglossaryid || $res->courseid != $lastcourseid) {
$cm = get_coursemodule_from_instance('glossary', $res->glossaryid, $res->courseid);
if ($cm) {
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
}
$lastglossaryid = $res->glossaryid;
$lastcourseid = $res->courseid;
}
$cmt = new stdClass();
$cmt->contextid = $modcontext->id;
$cmt->commentarea = 'glossary_entry';
$cmt->itemid = $res->itemid;
$cmt->content = $res->commentcontent;
$cmt->format = $res->format;
$cmt->userid = $res->userid;
$cmt->timecreated = $res->timemodified;
$cmt_id = $DB->insert_record('comments', $cmt);
if (!empty($cmt_id)) {
$DB->delete_records('glossary_comments', array('id'=>$res->old_id));
}
}
$rs->close();
$dbman->drop_table($table);
}

View file

@ -506,7 +506,8 @@ function glossary_upgrade_grades() {
$sql = "SELECT g.*, cm.idnumber AS cmidnumber, g.course AS courseid
FROM {glossary} g, {course_modules} cm, {modules} m
WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id";
if ($rs = $DB->get_recordset_sql($sql)) {
$rs = $DB->get_recordset_sql($sql);
if ($rs->valid()) {
$pbar = new progress_bar('glossaryupgradegrades', 500, true);
$i=0;
foreach ($rs as $glossary) {
@ -515,8 +516,8 @@ function glossary_upgrade_grades() {
glossary_update_grades($glossary, 0, false);
$pbar->update($i, $count, "Updating Glossary grades ($i/$count).");
}
$rs->close();
}
$rs->close();
}
/**
@ -2462,7 +2463,8 @@ function glossary_reset_userdata($data) {
$course_context = get_context_instance(CONTEXT_COURSE, $data->courseid);
$notenrolled = array();
if ($rs = $DB->get_recordset_sql($entriessql, $params)) {
$rs = $DB->get_recordset_sql($entriessql, $params);
if ($rs->valid()) {
foreach ($rs as $entry) {
if (array_key_exists($entry->userid, $notenrolled) or !$entry->userexists or $entry->userdeleted
or !is_enrolled($course_context , $entry->userid)) {
@ -2479,9 +2481,9 @@ function glossary_reset_userdata($data) {
}
}
}
$rs->close();
$status[] = array('component'=>$componentstr, 'item'=>get_string('deletenotenrolled', 'glossary'), 'error'=>false);
}
$rs->close();
}
// remove all ratings

View file

@ -49,7 +49,9 @@ function imscp_20_migrate() {
return;
}
if (!$candidates = $DB->get_recordset('resource_old', array('type'=>'ims', 'migrated'=>0))) {
$candidates = $DB->get_recordset('resource_old', array('type'=>'ims', 'migrated'=>0));
if (!$candidates->valid()) {
$candidates->close(); // Not going to iterate (but exit), close rs
return;
}
@ -133,7 +135,6 @@ function imscp_20_migrate() {
fulldelete($root);
}
}
$candidates->close();
// clear all course modinfo caches

View file

@ -429,7 +429,8 @@ function lesson_upgrade_grades() {
$sql = "SELECT l.*, cm.idnumber AS cmidnumber, l.course AS courseid
FROM {lesson} l, {course_modules} cm, {modules} m
WHERE m.name='lesson' AND m.id=cm.module AND cm.instance=l.id";
if ($rs = $DB->get_recordset_sql($sql)) {
$rs = $DB->get_recordset_sql($sql);
if ($rs->valid()) {
$pbar = new progress_bar('lessonupgradegrades', 500, true);
$i=0;
foreach ($rs as $lesson) {
@ -438,8 +439,8 @@ function lesson_upgrade_grades() {
lesson_update_grades($lesson, 0, false);
$pbar->update($i, $count, "Updating Lesson grades ($i/$count).");
}
$rs->close();
}
$rs->close();
}
/**

View file

@ -51,24 +51,22 @@ function page_20_migrate() {
$fs = get_file_storage();
if ($candidates = $DB->get_recordset('resource_old', array('type'=>'html', 'migrated'=>0))) {
foreach ($candidates as $candidate) {
page_20_migrate_candidate($candidate, $fs, FORMAT_HTML);
}
$candidates->close();
$candidates = $DB->get_recordset('resource_old', array('type'=>'html', 'migrated'=>0));
foreach ($candidates as $candidate) {
page_20_migrate_candidate($candidate, $fs, FORMAT_HTML);
}
$candidates->close();
if ($candidates = $DB->get_recordset('resource_old', array('type'=>'text', 'migrated'=>0))) {
foreach ($candidates as $candidate) {
//there might be some rubbish instead of format int value
$format = (int)$candidate->reference;
if ($format < 0 or $format > 4) {
$format = FORMAT_MOODLE;
}
page_20_migrate_candidate($candidate, $fs, $format);
$candidates = $DB->get_recordset('resource_old', array('type'=>'text', 'migrated'=>0));
foreach ($candidates as $candidate) {
//there might be some rubbish instead of format int value
$format = (int)$candidate->reference;
if ($format < 0 or $format > 4) {
$format = FORMAT_MOODLE;
}
$candidates->close();
page_20_migrate_candidate($candidate, $fs, $format);
}
$candidates->close();
// clear all course modinfo caches
rebuild_course_cache(0, true);

View file

@ -604,7 +604,8 @@ function quiz_upgrade_grades() {
$sql = "SELECT a.*, cm.idnumber AS cmidnumber, a.course AS courseid
FROM {quiz} a, {course_modules} cm, {modules} m
WHERE m.name='quiz' AND m.id=cm.module AND cm.instance=a.id";
if ($rs = $DB->get_recordset_sql($sql)) {
$rs = $DB->get_recordset_sql($sql);
if ($rs->valid()) {
$pbar = new progress_bar('quizupgradegrades', 500, true);
$i=0;
foreach ($rs as $quiz) {
@ -613,8 +614,8 @@ function quiz_upgrade_grades() {
quiz_update_grades($quiz, 0, false);
$pbar->update($i, $count, "Updating Quiz grades ($i/$count).");
}
$rs->close();
}
$rs->close();
}
/**

View file

@ -226,17 +226,17 @@ function xmldb_resource_upgrade($oldversion) {
JOIN {modules} m ON m.name='resource'
JOIN {course_modules} cm ON (cm.module = m.id AND cm.instance = r.id)";
if ($instances = $DB->get_recordset_sql($sql)) {
foreach ($instances as $instance) {
$context = get_context_instance(CONTEXT_MODULE, $instance->cmid);
$component = 'mod_resource';
$filearea = 'content';
$itemid = 0;
$filepath = file_correct_filepath(dirname($instance->mainfile));
$filename = basename($instance->mainfile);
file_set_sortorder($context->id, $component, $filearea, $itemid, $filepath, $filename, 1);
}
$instances = $DB->get_recordset_sql($sql);
foreach ($instances as $instance) {
$context = get_context_instance(CONTEXT_MODULE, $instance->cmid);
$component = 'mod_resource';
$filearea = 'content';
$itemid = 0;
$filepath = file_correct_filepath(dirname($instance->mainfile));
$filename = basename($instance->mainfile);
file_set_sortorder($context->id, $component, $filearea, $itemid, $filepath, $filename, 1);
}
$instances->close();
/// Define field mainfile to be dropped from resource
$table = new xmldb_table('resource');

View file

@ -42,7 +42,9 @@ function resource_20_migrate() {
$withrelativelinks = array('text/html', 'text/xml', 'application/xhtml+xml', 'application/x-shockwave-flash');
// note: pdf doc and other types may contain links too, but we do not support relative links there
if (!$candidates = $DB->get_recordset('resource_old', array('type'=>'file', 'migrated'=>0))) {
$candidates = $DB->get_recordset('resource_old', array('type'=>'file', 'migrated'=>0));
if (!$candidates->valid()) {
$candidates->close(); // Not going to iterate (but exit), close rs
return;
}

View file

@ -140,7 +140,8 @@ function xmldb_scorm_upgrade($oldversion) {
$count = $DB->count_records_sql("SELECT COUNT('x') $sqlfrom");
if ($rs = $DB->get_recordset_sql("SELECT s.id, s.scormtype, s.reference, s.course, cm.id AS cmid $sqlfrom ORDER BY s.course, s.id")) {
$rs = $DB->get_recordset_sql("SELECT s.id, s.scormtype, s.reference, s.course, cm.id AS cmid $sqlfrom ORDER BY s.course, s.id");
if ($rs->valid()) {
$pbar = new progress_bar('migratescormfiles', 500, true);
@ -213,8 +214,8 @@ function xmldb_scorm_upgrade($oldversion) {
@rmdir("$CFG->dataroot/$scorm->course/$CFG->moddata/scorm/");
@rmdir("$CFG->dataroot/$scorm->course/$CFG->moddata/");
}
$rs->close();
}
$rs->close();
/// scorm savepoint reached
upgrade_mod_savepoint(true, 2008090304, 'scorm');

View file

@ -575,7 +575,8 @@ function scorm_upgrade_grades() {
$sql = "SELECT s.*, cm.idnumber AS cmidnumber, s.course AS courseid
FROM {scorm} s, {course_modules} cm, {modules} m
WHERE m.name='scorm' AND m.id=cm.module AND cm.instance=s.id";
if ($rs = $DB->get_recordset_sql($sql)) {
$rs = $DB->get_recordset_sql($sql);
if ($rs->valid()) {
$pbar = new progress_bar('scormupgradegrades', 500, true);
$i=0;
foreach ($rs as $scorm) {
@ -584,8 +585,8 @@ function scorm_upgrade_grades() {
scorm_update_grades($scorm, 0, false);
$pbar->update($i, $count, "Updating Scorm grades ($i/$count).");
}
$rs->close();
}
$rs->close();
}
/**

View file

@ -232,13 +232,15 @@ function survey_print_recent_activity($course, $viewfullnames, $timestart) {
$slist = implode(',', $ids); // there should not be hundreds of glossaries in one course, right?
if (!$rs = $DB->get_recordset_sql("SELECT sa.userid, sa.survey, MAX(sa.time) AS time,
u.firstname, u.lastname, u.email, u.picture
FROM {survey_answers} sa
JOIN {user} u ON u.id = sa.userid
WHERE sa.survey IN ($slist) AND sa.time > ?
GROUP BY sa.userid, sa.survey, u.firstname, u.lastname, u.email, u.picture
ORDER BY time ASC", array($timestart))) {
$rs = $DB->get_recordset_sql("SELECT sa.userid, sa.survey, MAX(sa.time) AS time,
u.firstname, u.lastname, u.email, u.picture
FROM {survey_answers} sa
JOIN {user} u ON u.id = sa.userid
WHERE sa.survey IN ($slist) AND sa.time > ?
GROUP BY sa.userid, sa.survey, u.firstname, u.lastname, u.email, u.picture
ORDER BY time ASC", array($timestart));
if (!$rs->valid()) {
$rs->close(); // Not going to iterate (but exit), close rs
return false;
}

View file

@ -50,7 +50,9 @@ function url_20_migrate() {
return;
}
if (!$candidates = $DB->get_recordset('resource_old', array('type'=>'file', 'migrated'=>0))) {
$candidates = $DB->get_recordset('resource_old', array('type'=>'file', 'migrated'=>0));
if (!$candidates->valid()) {
$candidates->close(); // Not going to iterate (but exit), close rs
return;
}
@ -135,4 +137,4 @@ function url_20_migrate() {
// clear all course modinfo caches
rebuild_course_cache(0, true);
}
}