mirror of
https://github.com/moodle/moodle.git
synced 2025-08-02 07:39:54 +02:00
MDL-14679 fixed remaining old style set_field()s
This commit is contained in:
parent
dd88de0ebd
commit
f685e83030
26 changed files with 82 additions and 167 deletions
|
@ -1059,7 +1059,7 @@ class test extends XMLDBAction {
|
||||||
$rec->name = 'updatelobs';
|
$rec->name = 'updatelobs';
|
||||||
/// Calculate its length
|
/// Calculate its length
|
||||||
$textlen = $textlib->strlen($fulltext);
|
$textlen = $textlib->strlen($fulltext);
|
||||||
if ($DB->set_field('newnameforthetable', 'intro', $rec->intro, array('name'=>$rec->name))) {
|
$DB->set_field('newnameforthetable', 'intro', $rec->intro, array('name'=>$rec->name));
|
||||||
if ($new = $DB->get_record('newnameforthetable', array('id'=>$rec->id))) {
|
if ($new = $DB->get_record('newnameforthetable', array('id'=>$rec->id))) {
|
||||||
$newtextlen = $textlib->strlen($new->intro);
|
$newtextlen = $textlib->strlen($new->intro);
|
||||||
if ($fulltext === $new->intro) {
|
if ($fulltext === $new->intro) {
|
||||||
|
@ -1073,9 +1073,6 @@ class test extends XMLDBAction {
|
||||||
} else {
|
} else {
|
||||||
$test->error = $DB->get_last_error();
|
$test->error = $DB->get_last_error();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$test->error = $DB->get_last_error();
|
|
||||||
}
|
|
||||||
$tests['set field '. $textlen . ' cc. (text)'] = $test;
|
$tests['set field '. $textlen . ' cc. (text)'] = $test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1089,7 +1086,7 @@ class test extends XMLDBAction {
|
||||||
$rec->name = 'updatelobs';
|
$rec->name = 'updatelobs';
|
||||||
/// Calculate its length
|
/// Calculate its length
|
||||||
$textlen = strlen($rec->avatar);
|
$textlen = strlen($rec->avatar);
|
||||||
if ($DB->set_field('newnameforthetable', 'avatar', $rec->avatar, array('name'=>$rec->name))) {
|
$DB->set_field('newnameforthetable', 'avatar', $rec->avatar, array('name'=>$rec->name));
|
||||||
if ($new = $DB->get_record('newnameforthetable', array('id'=>$rec->id))) {
|
if ($new = $DB->get_record('newnameforthetable', array('id'=>$rec->id))) {
|
||||||
$newtextlen = strlen($new->avatar);
|
$newtextlen = strlen($new->avatar);
|
||||||
if ($rec->avatar === $new->avatar) {
|
if ($rec->avatar === $new->avatar) {
|
||||||
|
@ -1103,9 +1100,6 @@ class test extends XMLDBAction {
|
||||||
} else {
|
} else {
|
||||||
$test->error = $DB->get_last_error();
|
$test->error = $DB->get_last_error();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$test->error = $DB->get_last_error();
|
|
||||||
}
|
|
||||||
$tests['set field '. $textlen . ' bytes (binary)'] = $test;
|
$tests['set field '. $textlen . ' bytes (binary)'] = $test;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,12 +131,8 @@ class auth_plugin_email extends auth_plugin_base {
|
||||||
return AUTH_CONFIRM_ERROR;
|
return AUTH_CONFIRM_ERROR;
|
||||||
|
|
||||||
} else if ($user->secret == $confirmsecret) { // They have provided the secret key to get in
|
} else if ($user->secret == $confirmsecret) { // They have provided the secret key to get in
|
||||||
if (!$DB->set_field("user", "confirmed", 1, array("id"=>$user->id))) {
|
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
|
||||||
return AUTH_CONFIRM_FAIL;
|
$DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
|
||||||
}
|
|
||||||
if (!$DB->set_field("user", "firstaccess", time(), array("id"=>$user->id))) {
|
|
||||||
return AUTH_CONFIRM_FAIL;
|
|
||||||
}
|
|
||||||
return AUTH_CONFIRM_OK;
|
return AUTH_CONFIRM_OK;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -549,12 +549,8 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||||
if (!$this->user_activate($username)) {
|
if (!$this->user_activate($username)) {
|
||||||
return AUTH_CONFIRM_FAIL;
|
return AUTH_CONFIRM_FAIL;
|
||||||
}
|
}
|
||||||
if (!$DB->set_field('user', 'confirmed', 1, array('id'=>$user->id))) {
|
$DB->set_field('user', 'confirmed', 1, array('id'=>$user->id));
|
||||||
return AUTH_CONFIRM_FAIL;
|
$DB->set_field('user', 'firstaccess', time(), array('id'=>$user->id));
|
||||||
}
|
|
||||||
if (!$DB->set_field('user', 'firstaccess', time(), array('id'=>$user->id))) {
|
|
||||||
return AUTH_CONFIRM_FAIL;
|
|
||||||
}
|
|
||||||
return AUTH_CONFIRM_OK;
|
return AUTH_CONFIRM_OK;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -137,12 +137,8 @@ class auth_plugin_manual extends auth_plugin_base {
|
||||||
if ($user->confirmed) {
|
if ($user->confirmed) {
|
||||||
return AUTH_CONFIRM_ALREADY;
|
return AUTH_CONFIRM_ALREADY;
|
||||||
} else {
|
} else {
|
||||||
if (!$DB->set_field("user", "confirmed", 1, array("id"=>$user->id))) {
|
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
|
||||||
return AUTH_CONFIRM_FAIL;
|
$DB->set_field("user", "firstaccess", time(), array("id"=>$user->id));
|
||||||
}
|
|
||||||
if (!$DB->set_field("user", "firstaccess", time(), array("id"=>$user->id))) {
|
|
||||||
return AUTH_CONFIRM_FAIL;
|
|
||||||
}
|
|
||||||
return AUTH_CONFIRM_OK;
|
return AUTH_CONFIRM_OK;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -43,9 +43,7 @@ $context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||||
|
|
||||||
if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
|
if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
|
||||||
$course->marker = $marker;
|
$course->marker = $marker;
|
||||||
if (! $DB->set_field("course", "marker", $marker, array("id"=>$course->id))) {
|
$DB->set_field("course", "marker", $marker, array("id"=>$course->id));
|
||||||
print_error("cannotmarktopic");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$streditsummary = get_string('editsummary');
|
$streditsummary = get_string('editsummary');
|
||||||
|
|
|
@ -1735,9 +1735,7 @@ function rebuild_course_cache($courseid=0, $clearonly=false) {
|
||||||
if ($rs = $DB->get_recordset("course", $select,'','id,fullname')) {
|
if ($rs = $DB->get_recordset("course", $select,'','id,fullname')) {
|
||||||
foreach ($rs as $course) {
|
foreach ($rs as $course) {
|
||||||
$modinfo = serialize(get_array_of_activities($course->id));
|
$modinfo = serialize(get_array_of_activities($course->id));
|
||||||
if (!$DB->set_field("course", "modinfo", $modinfo, array("id"=>$course->id))) {
|
$DB->set_field("course", "modinfo", $modinfo, array("id"=>$course->id));
|
||||||
echo $OUTPUT->notification("Could not cache module information for course '" . format_string($course->fullname) . "'!");
|
|
||||||
}
|
|
||||||
// update cached global COURSE too ;-)
|
// update cached global COURSE too ;-)
|
||||||
if ($course->id == $COURSE->id) {
|
if ($course->id == $COURSE->id) {
|
||||||
$COURSE->modinfo = $modinfo;
|
$COURSE->modinfo = $modinfo;
|
||||||
|
@ -2547,11 +2545,8 @@ function add_mod_to_section($mod, $beforemod=NULL) {
|
||||||
$newsequence = "$section->sequence,$mod->coursemodule";
|
$newsequence = "$section->sequence,$mod->coursemodule";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($DB->set_field("course_sections", "sequence", $newsequence, array("id"=>$section->id))) {
|
$DB->set_field("course_sections", "sequence", $newsequence, array("id"=>$section->id));
|
||||||
return $section->id; // Return course_sections ID that was used.
|
return $section->id; // Return course_sections ID that was used.
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else { // Insert a new record
|
} else { // Insert a new record
|
||||||
$section->course = $mod->course;
|
$section->course = $mod->course;
|
||||||
|
@ -2703,12 +2698,9 @@ function move_section($course, $section, $move) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$DB->set_field("course_sections", "section", $sectiondest, array("id"=>$sectionrecord->id))) {
|
$DB->set_field("course_sections", "section", $sectiondest, array("id"=>$sectionrecord->id));
|
||||||
return false;
|
$DB->set_field("course_sections", "section", $section, array("id"=>$sectiondestrecord->id));
|
||||||
}
|
|
||||||
if (!$DB->set_field("course_sections", "section", $section, array("id"=>$sectiondestrecord->id))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// if the focus is on the section that is being moved, then move the focus along
|
// if the focus is on the section that is being moved, then move the focus along
|
||||||
if (isset($USER->display[$course->id]) and ($USER->display[$course->id] == $section)) {
|
if (isset($USER->display[$course->id]) and ($USER->display[$course->id] == $section)) {
|
||||||
course_set_display($course->id, $sectiondest);
|
course_set_display($course->id, $sectiondest);
|
||||||
|
@ -2720,9 +2712,7 @@ function move_section($course, $section, $move) {
|
||||||
$n = 0;
|
$n = 0;
|
||||||
foreach ($sections as $section) {
|
foreach ($sections as $section) {
|
||||||
if ($section->section != $n) {
|
if ($section->section != $n) {
|
||||||
if (!$DB->set_field('course_sections', 'section', $n, array('id'=>$section->id))) {
|
$DB->set_field('course_sections', 'section', $n, array('id'=>$section->id));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$n++;
|
$n++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,9 +68,7 @@
|
||||||
$visible = 1;
|
$visible = 1;
|
||||||
}
|
}
|
||||||
if ($course) {
|
if ($course) {
|
||||||
if (! $DB->set_field("course", "visible", $visible, array("id"=>$course->id))) {
|
$DB->set_field("course", "visible", $visible, array("id"=>$course->id));
|
||||||
echo $OUTPUT->notification("Could not update that course!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,7 @@ function cron_run() {
|
||||||
$pre_dbqueries = $DB->perf_get_queries();
|
$pre_dbqueries = $DB->perf_get_queries();
|
||||||
$pre_time = microtime(1);
|
$pre_time = microtime(1);
|
||||||
if ($cron_function()) {
|
if ($cron_function()) {
|
||||||
if (!$DB->set_field("modules", "lastcron", $timenow, array("id"=>$mod->id))) {
|
$DB->set_field("modules", "lastcron", $timenow, array("id"=>$mod->id));
|
||||||
mtrace("Error: could not update timestamp for $mod->fullname");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isset($pre_dbqueries)) {
|
if (isset($pre_dbqueries)) {
|
||||||
mtrace("... used " . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries");
|
mtrace("... used " . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries");
|
||||||
|
@ -106,9 +104,7 @@ function cron_run() {
|
||||||
if (method_exists($blockobj,'cron')) {
|
if (method_exists($blockobj,'cron')) {
|
||||||
mtrace("Processing cron function for ".$block->name.'....','');
|
mtrace("Processing cron function for ".$block->name.'....','');
|
||||||
if ($blockobj->cron()) {
|
if ($blockobj->cron()) {
|
||||||
if (!$DB->set_field('block', 'lastcron', $timenow, array('id'=>$block->id))) {
|
$DB->set_field('block', 'lastcron', $timenow, array('id'=>$block->id));
|
||||||
mtrace('Error: could not update timestamp for '.$block->name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// Reset possible changes by blocks to time_limit. MDL-11597
|
/// Reset possible changes by blocks to time_limit. MDL-11597
|
||||||
@set_time_limit(0);
|
@set_time_limit(0);
|
||||||
|
@ -133,9 +129,7 @@ function cron_run() {
|
||||||
$pre_dbqueries = $DB->perf_get_queries();
|
$pre_dbqueries = $DB->perf_get_queries();
|
||||||
$pre_time = microtime(1);
|
$pre_time = microtime(1);
|
||||||
if ($cron_function()) {
|
if ($cron_function()) {
|
||||||
if (!$DB->set_field('quiz_report', "lastcron", $timenow, array("id"=>$report->id))) {
|
$DB->set_field('quiz_report', "lastcron", $timenow, array("id"=>$report->id));
|
||||||
mtrace("Error: could not update timestamp for $report->name");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isset($pre_dbqueries)) {
|
if (isset($pre_dbqueries)) {
|
||||||
mtrace("... used " . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries");
|
mtrace("... used " . ($DB->perf_get_queries() - $pre_dbqueries) . " dbqueries");
|
||||||
|
|
|
@ -431,10 +431,9 @@ class grade_item extends grade_object {
|
||||||
if (!empty($cm->idnumber)) {
|
if (!empty($cm->idnumber)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($DB->set_field('course_modules', 'idnumber', $idnumber, array('id' => $cm->id))) {
|
$DB->set_field('course_modules', 'idnumber', $idnumber, array('id' => $cm->id));
|
||||||
$this->idnumber = $idnumber;
|
$this->idnumber = $idnumber;
|
||||||
return $this->update();
|
return $this->update();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$this->idnumber = $idnumber;
|
$this->idnumber = $idnumber;
|
||||||
return $this->update();
|
return $this->update();
|
||||||
|
|
|
@ -340,9 +340,7 @@ class moodle_list {
|
||||||
function reorder_peers($peers) {
|
function reorder_peers($peers) {
|
||||||
global $DB;
|
global $DB;
|
||||||
foreach ($peers as $key => $peer) {
|
foreach ($peers as $key => $peer) {
|
||||||
if (!$DB->set_field($this->table, "sortorder", $key, array("id"=>$peer))) {
|
$DB->set_field($this->table, "sortorder", $key, array("id"=>$peer));
|
||||||
print_error('listupdatefail');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,14 +361,11 @@ class moodle_list {
|
||||||
} else {
|
} else {
|
||||||
$newparent = 0; // top level item
|
$newparent = 0; // top level item
|
||||||
}
|
}
|
||||||
if (!$DB->set_field($this->table, "parent", $newparent, array("id"=>$item->id))) {
|
$DB->set_field($this->table, "parent", $newparent, array("id"=>$item->id));
|
||||||
print_error('listupdatefail');
|
|
||||||
} else {
|
|
||||||
$oldparentkey = array_search($item->parentlist->parentitem->id, $newpeers);
|
$oldparentkey = array_search($item->parentlist->parentitem->id, $newpeers);
|
||||||
$neworder = array_merge(array_slice($newpeers, 0, $oldparentkey+1), array($item->id), array_slice($newpeers, $oldparentkey+1));
|
$neworder = array_merge(array_slice($newpeers, 0, $oldparentkey+1), array($item->id), array_slice($newpeers, $oldparentkey+1));
|
||||||
$this->reorder_peers($neworder);
|
$this->reorder_peers($neworder);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $item->parentlist->parentitem;
|
return $item->parentlist->parentitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,9 +382,7 @@ class moodle_list {
|
||||||
if (!isset($peers[$itemkey-1])) {
|
if (!isset($peers[$itemkey-1])) {
|
||||||
print_error('listcantmoveright');
|
print_error('listcantmoveright');
|
||||||
} else {
|
} else {
|
||||||
if (!$DB->set_field($this->table, "parent", $peers[$itemkey-1], array("id"=>$peers[$itemkey]))) {
|
$DB->set_field($this->table, "parent", $peers[$itemkey-1], array("id"=>$peers[$itemkey]));
|
||||||
print_error('listupdatefail');
|
|
||||||
} else {
|
|
||||||
$newparent = $this->find_item($peers[$itemkey-1]);
|
$newparent = $this->find_item($peers[$itemkey-1]);
|
||||||
if (isset($newparent->children)) {
|
if (isset($newparent->children)) {
|
||||||
$newpeers = $newparent->children->get_child_ids();
|
$newpeers = $newparent->children->get_child_ids();
|
||||||
|
@ -400,7 +393,6 @@ class moodle_list {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* process any actions.
|
* process any actions.
|
||||||
|
|
|
@ -748,9 +748,7 @@ function question_delete_course_category($category, $newcategory, $feedback=true
|
||||||
if (!$newcontext = get_context_instance(CONTEXT_COURSECAT, $newcategory->id)) {
|
if (!$newcontext = get_context_instance(CONTEXT_COURSECAT, $newcategory->id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!$DB->set_field('question_categories', 'contextid', $newcontext->id, array('contextid'=>$context->id))) {
|
$DB->set_field('question_categories', 'contextid', $newcontext->id, array('contextid'=>$context->id));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($feedback) {
|
if ($feedback) {
|
||||||
$a = new stdClass;
|
$a = new stdClass;
|
||||||
$a->oldplace = print_context_name($context);
|
$a->oldplace = print_context_name($context);
|
||||||
|
@ -855,7 +853,7 @@ function question_delete_activity($cm, $feedback=true) {
|
||||||
*/
|
*/
|
||||||
function question_move_questions_to_category($questionids, $newcategoryid) {
|
function question_move_questions_to_category($questionids, $newcategoryid) {
|
||||||
global $DB, $QTYPES;
|
global $DB, $QTYPES;
|
||||||
$result = true;
|
|
||||||
$ids = explode(',', $questionids);
|
$ids = explode(',', $questionids);
|
||||||
foreach ($ids as $questionid) {
|
foreach ($ids as $questionid) {
|
||||||
$questionid = (int)$questionid;
|
$questionid = (int)$questionid;
|
||||||
|
@ -872,14 +870,14 @@ function question_move_questions_to_category($questionids, $newcategoryid) {
|
||||||
|
|
||||||
|
|
||||||
// Move the questions themselves.
|
// Move the questions themselves.
|
||||||
$result = $result && $DB->set_field_select('question', 'category', $newcategoryid, "id IN ($questionids)");
|
$DB->set_field_select('question', 'category', $newcategoryid, "id IN ($questionids)");
|
||||||
|
|
||||||
// Move any subquestions belonging to them.
|
// Move any subquestions belonging to them.
|
||||||
$result = $result && $DB->set_field_select('question', 'category', $newcategoryid, "parent IN ($questionids)");
|
$DB->set_field_select('question', 'category', $newcategoryid, "parent IN ($questionids)");
|
||||||
|
|
||||||
// TODO Deal with datasets.
|
// TODO Deal with datasets.
|
||||||
|
|
||||||
return $result;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1957,9 +1955,7 @@ function question_process_comment($question, &$state, &$attempt, $comment, $grad
|
||||||
$comment = trim($comment);
|
$comment = trim($comment);
|
||||||
$state->manualcomment = $comment;
|
$state->manualcomment = $comment;
|
||||||
$state->newflaggedstate = $state->flagged;
|
$state->newflaggedstate = $state->flagged;
|
||||||
if (!$DB->set_field('question_sessions', 'manualcomment', $comment, array('attemptid'=>$attempt->uniqueid, 'questionid'=>$question->id))) {
|
$DB->set_field('question_sessions', 'manualcomment', $comment, array('attemptid'=>$attempt->uniqueid, 'questionid'=>$question->id));
|
||||||
return get_string('errorsavingcomment', 'question', $question);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the attempt if the score has changed.
|
// Update the attempt if the score has changed.
|
||||||
if ($grade !== '' && (abs($state->last_graded->grade - $grade) > 0.002 || $state->last_graded->event != QUESTION_EVENTMANUALGRADE)) {
|
if ($grade !== '' && (abs($state->last_graded->grade - $grade) > 0.002 || $state->last_graded->event != QUESTION_EVENTMANUALGRADE)) {
|
||||||
|
|
|
@ -2511,10 +2511,7 @@ function assignment_cron () {
|
||||||
$realuser = clone($USER);
|
$realuser = clone($USER);
|
||||||
|
|
||||||
foreach ($submissions as $key => $submission) {
|
foreach ($submissions as $key => $submission) {
|
||||||
if (! $DB->set_field("assignment_submissions", "mailed", "1", array("id"=>$submission->id))) {
|
$DB->set_field("assignment_submissions", "mailed", "1", array("id"=>$submission->id));
|
||||||
echo "Could not update the mailed field for id $submission->id. Not mailed.\n";
|
|
||||||
unset($submissions[$key]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$timenow = time();
|
$timenow = time();
|
||||||
|
|
|
@ -2944,10 +2944,8 @@ function forum_get_course_forum($courseid, $type) {
|
||||||
echo $OUTPUT->notification("Could not add the new course module to that section");
|
echo $OUTPUT->notification("Could not add the new course module to that section");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (! $DB->set_field("course_modules", "section", $sectionid, array("id" => $mod->coursemodule))) {
|
$DB->set_field("course_modules", "section", $sectionid, array("id" => $mod->coursemodule));
|
||||||
echo $OUTPUT->notification("Could not update the course module with the correct section");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
include_once("$CFG->dirroot/course/lib.php");
|
include_once("$CFG->dirroot/course/lib.php");
|
||||||
rebuild_course_cache($courseid);
|
rebuild_course_cache($courseid);
|
||||||
|
|
||||||
|
|
|
@ -139,9 +139,7 @@ function quiz_add_quiz_question($id, &$quiz, $page = 0) {
|
||||||
|
|
||||||
// Save new questionslist in database
|
// Save new questionslist in database
|
||||||
$quiz->questions = implode(',', $questions);
|
$quiz->questions = implode(',', $questions);
|
||||||
if (!$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id))) {
|
$DB->set_field('quiz', 'questions', $quiz->questions, array('id' => $quiz->id));
|
||||||
print_error('cannotsavequestion', 'quiz');
|
|
||||||
}
|
|
||||||
|
|
||||||
// update question grades
|
// update question grades
|
||||||
$quiz->grades[$id] = $DB->get_field('question', 'defaultgrade', array('id' => $id));
|
$quiz->grades[$id] = $DB->get_field('question', 'defaultgrade', array('id' => $id));
|
||||||
|
|
|
@ -170,9 +170,7 @@
|
||||||
}
|
}
|
||||||
$sortorder = 0;
|
$sortorder = 0;
|
||||||
foreach ($peers as $peer) {
|
foreach ($peers as $peer) {
|
||||||
if (! $DB->set_field('question_categories', "sortorder", $sortorder, array("id" => $peer))) {
|
$DB->set_field('question_categories', "sortorder", $sortorder, array("id" => $peer));
|
||||||
print_error('listupdatefail', '', $onerrorurl);
|
|
||||||
}
|
|
||||||
$sortorder++;
|
$sortorder++;
|
||||||
}
|
}
|
||||||
//now move category
|
//now move category
|
||||||
|
|
|
@ -1448,10 +1448,9 @@ class question_bank_view {
|
||||||
$questionid = (int)$questionid;
|
$questionid = (int)$questionid;
|
||||||
question_require_capability_on($questionid, 'edit');
|
question_require_capability_on($questionid, 'edit');
|
||||||
if ($DB->record_exists('quiz_question_instances', array('question' => $questionid))) {
|
if ($DB->record_exists('quiz_question_instances', array('question' => $questionid))) {
|
||||||
if (!$DB->set_field('question', 'hidden', 1, array('id' => $questionid))) {
|
$DB->set_field('question', 'hidden', 1, array('id' => $questionid));
|
||||||
question_require_capability_on($questionid, 'edit');
|
question_require_capability_on($questionid, 'edit');
|
||||||
print_error('cannothidequestion', 'question');
|
print_error('cannothidequestion', 'question');
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
delete_question($questionid);
|
delete_question($questionid);
|
||||||
}
|
}
|
||||||
|
@ -1467,9 +1466,7 @@ class question_bank_view {
|
||||||
// Unhide a question
|
// Unhide a question
|
||||||
if(($unhide = optional_param('unhide', '', PARAM_INT)) and confirm_sesskey()) {
|
if(($unhide = optional_param('unhide', '', PARAM_INT)) and confirm_sesskey()) {
|
||||||
question_require_capability_on($unhide, 'edit');
|
question_require_capability_on($unhide, 'edit');
|
||||||
if(!$DB->set_field('question', 'hidden', 0, array('id' => $unhide))) {
|
$DB->set_field('question', 'hidden', 0, array('id' => $unhide));
|
||||||
print_error('cannotunhidequestion', 'question');
|
|
||||||
}
|
|
||||||
redirect($this->baseurl);
|
redirect($this->baseurl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,7 +417,7 @@
|
||||||
// see: $QTYPES['random']->get_question_options()
|
// see: $QTYPES['random']->get_question_options()
|
||||||
if ($question->qtype == 'random' && $creatingnewquestion) {
|
if ($question->qtype == 'random' && $creatingnewquestion) {
|
||||||
$question->parent = $question->id;
|
$question->parent = $question->id;
|
||||||
$status = $DB->set_field('question', 'parent', $question->parent, array('id'=>$question->id));
|
$DB->set_field('question', 'parent', $question->parent, array('id'=>$question->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save newid to backup tables
|
//Save newid to backup tables
|
||||||
|
@ -457,10 +457,7 @@
|
||||||
if ($parent = backup_getid($restore->backup_unique_code,"question",$question->parent)) {
|
if ($parent = backup_getid($restore->backup_unique_code,"question",$question->parent)) {
|
||||||
$question->parent = $parent->new_id;
|
$question->parent = $parent->new_id;
|
||||||
if ($question->parent != $restored_questions[$i]->parent) {
|
if ($question->parent != $restored_questions[$i]->parent) {
|
||||||
if (!$DB->set_field('question', 'parent', $question->parent, array('id'=>$newid))) {
|
$DB->set_field('question', 'parent', $question->parent, array('id'=>$newid));
|
||||||
echo 'Could not update parent '.$question->parent.' for question '.$oldid.'<br />';
|
|
||||||
$status = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo 'Could not recode parent '.$question->parent.' for question '.$oldid.'<br />';
|
echo 'Could not recode parent '.$question->parent.' for question '.$oldid.'<br />';
|
||||||
|
|
|
@ -394,9 +394,8 @@ class question_calculated_qtype extends default_questiontype {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the legacy answer field
|
// Set the legacy answer field
|
||||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id'=> $state->id))) {
|
$DB->set_field('question_states', 'answer', $responses, array('id'=> $state->id));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,9 +622,7 @@ class question_calculated_qtype extends default_questiontype {
|
||||||
}
|
}
|
||||||
$questionname ="#".$questionname;
|
$questionname ="#".$questionname;
|
||||||
}
|
}
|
||||||
if (!$DB->set_field('question', 'name', $questionname, array("id" => $question->id))) {
|
$DB->set_field('question', 'name', $questionname, array("id" => $question->id));
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -703,9 +700,7 @@ class question_calculated_qtype extends default_questiontype {
|
||||||
}else {
|
}else {
|
||||||
$options_synchronize = 0 ;
|
$options_synchronize = 0 ;
|
||||||
}
|
}
|
||||||
if (!$DB->set_field('question_calculated_options', 'synchronize', $options_synchronize, array("question" => $question->id))) {
|
$DB->set_field('question_calculated_options', 'synchronize', $options_synchronize, array("question" => $question->id));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(isset($form->synchronize) && $form->synchronize == 2 ){
|
if(isset($form->synchronize) && $form->synchronize == 2 ){
|
||||||
$this->addnamecategory($question);
|
$this->addnamecategory($question);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,9 +241,7 @@ class question_calculatedmulti_qtype extends question_calculated_qtype {
|
||||||
$responses .= implode(',', $state->responses);
|
$responses .= implode(',', $state->responses);
|
||||||
|
|
||||||
// Set the legacy answer field
|
// Set the legacy answer field
|
||||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id'=> $state->id))) {
|
$DB->set_field('question_states', 'answer', $responses, array('id'=> $state->id));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,9 +230,7 @@ class question_match_qtype extends default_questiontype {
|
||||||
$responses = implode(',', $responses);
|
$responses = implode(',', $responses);
|
||||||
|
|
||||||
// Set the legacy answer field
|
// Set the legacy answer field
|
||||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id))) {
|
$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,9 +210,7 @@ class embedded_cloze_qtype extends default_questiontype {
|
||||||
$responses = implode(',', $responses);
|
$responses = implode(',', $responses);
|
||||||
|
|
||||||
// Set the legacy answer field
|
// Set the legacy answer field
|
||||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id))) {
|
$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,9 +236,7 @@ class question_multichoice_qtype extends default_questiontype {
|
||||||
$responses .= implode(',', $state->responses);
|
$responses .= implode(',', $state->responses);
|
||||||
|
|
||||||
// Set the legacy answer field
|
// Set the legacy answer field
|
||||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id))) {
|
$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -416,9 +416,7 @@ class question_numerical_qtype extends question_shortanswer_qtype {
|
||||||
$responses = $state->responses['answer'].'|||||';
|
$responses = $state->responses['answer'].'|||||';
|
||||||
}
|
}
|
||||||
// Set the legacy answer field
|
// Set the legacy answer field
|
||||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id))) {
|
$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id));
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,8 +297,7 @@ class random_qtype extends default_questiontype {
|
||||||
$response = "random$realqid-$response";
|
$response = "random$realqid-$response";
|
||||||
|
|
||||||
// ... and save it again.
|
// ... and save it again.
|
||||||
if (!$DB->set_field('question_states', 'answer', $response, array('id' => $state->id))) {
|
$DB->set_field('question_states', 'answer', $response, array('id' => $state->id));
|
||||||
}
|
|
||||||
|
|
||||||
// Restore the real id
|
// Restore the real id
|
||||||
$wrappedquestion->id = $realqid;
|
$wrappedquestion->id = $realqid;
|
||||||
|
|
|
@ -1317,19 +1317,18 @@ abstract class repository {
|
||||||
$DB->update_record('repository_instances', $r);
|
$DB->update_record('repository_instances', $r);
|
||||||
unset($options['name']);
|
unset($options['name']);
|
||||||
}
|
}
|
||||||
$result = true;
|
|
||||||
foreach ($options as $name=>$value) {
|
foreach ($options as $name=>$value) {
|
||||||
if ($id = $DB->get_field('repository_instance_config', 'id', array('name'=>$name, 'instanceid'=>$this->id))) {
|
if ($id = $DB->get_field('repository_instance_config', 'id', array('name'=>$name, 'instanceid'=>$this->id))) {
|
||||||
$result = $result && $DB->set_field('repository_instance_config', 'value', $value, array('id'=>$id));
|
$DB->set_field('repository_instance_config', 'value', $value, array('id'=>$id));
|
||||||
} else {
|
} else {
|
||||||
$config = new object();
|
$config = new object();
|
||||||
$config->instanceid = $this->id;
|
$config->instanceid = $this->id;
|
||||||
$config->name = $name;
|
$config->name = $name;
|
||||||
$config->value = $value;
|
$config->value = $value;
|
||||||
$result = $result && $DB->insert_record('repository_instance_config', $config);
|
$DB->insert_record('repository_instance_config', $config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,9 +42,7 @@ if (!isloggedin()) {
|
||||||
|
|
||||||
if ($agree and confirm_sesskey()) { // User has agreed
|
if ($agree and confirm_sesskey()) { // User has agreed
|
||||||
if (!isguestuser()) { // Don't remember guests
|
if (!isguestuser()) { // Don't remember guests
|
||||||
if (!$DB->set_field('user', 'policyagreed', 1, array('id'=>$USER->id))) {
|
$DB->set_field('user', 'policyagreed', 1, array('id'=>$USER->id));
|
||||||
print_error('cannotsaveagreement');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$USER->policyagreed = 1;
|
$USER->policyagreed = 1;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue