mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +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
|
@ -170,9 +170,7 @@
|
|||
}
|
||||
$sortorder = 0;
|
||||
foreach ($peers as $peer) {
|
||||
if (! $DB->set_field('question_categories', "sortorder", $sortorder, array("id" => $peer))) {
|
||||
print_error('listupdatefail', '', $onerrorurl);
|
||||
}
|
||||
$DB->set_field('question_categories', "sortorder", $sortorder, array("id" => $peer));
|
||||
$sortorder++;
|
||||
}
|
||||
//now move category
|
||||
|
|
|
@ -1448,10 +1448,9 @@ class question_bank_view {
|
|||
$questionid = (int)$questionid;
|
||||
question_require_capability_on($questionid, 'edit');
|
||||
if ($DB->record_exists('quiz_question_instances', array('question' => $questionid))) {
|
||||
if (!$DB->set_field('question', 'hidden', 1, array('id' => $questionid))) {
|
||||
question_require_capability_on($questionid, 'edit');
|
||||
print_error('cannothidequestion', 'question');
|
||||
}
|
||||
$DB->set_field('question', 'hidden', 1, array('id' => $questionid));
|
||||
question_require_capability_on($questionid, 'edit');
|
||||
print_error('cannothidequestion', 'question');
|
||||
} else {
|
||||
delete_question($questionid);
|
||||
}
|
||||
|
@ -1467,9 +1466,7 @@ class question_bank_view {
|
|||
// Unhide a question
|
||||
if(($unhide = optional_param('unhide', '', PARAM_INT)) and confirm_sesskey()) {
|
||||
question_require_capability_on($unhide, 'edit');
|
||||
if(!$DB->set_field('question', 'hidden', 0, array('id' => $unhide))) {
|
||||
print_error('cannotunhidequestion', 'question');
|
||||
}
|
||||
$DB->set_field('question', 'hidden', 0, array('id' => $unhide));
|
||||
redirect($this->baseurl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -417,7 +417,7 @@
|
|||
// see: $QTYPES['random']->get_question_options()
|
||||
if ($question->qtype == 'random' && $creatingnewquestion) {
|
||||
$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
|
||||
|
@ -457,10 +457,7 @@
|
|||
if ($parent = backup_getid($restore->backup_unique_code,"question",$question->parent)) {
|
||||
$question->parent = $parent->new_id;
|
||||
if ($question->parent != $restored_questions[$i]->parent) {
|
||||
if (!$DB->set_field('question', 'parent', $question->parent, array('id'=>$newid))) {
|
||||
echo 'Could not update parent '.$question->parent.' for question '.$oldid.'<br />';
|
||||
$status = false;
|
||||
}
|
||||
$DB->set_field('question', 'parent', $question->parent, array('id'=>$newid));
|
||||
}
|
||||
} else {
|
||||
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
|
||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id'=> $state->id))) {
|
||||
return false;
|
||||
}
|
||||
$DB->set_field('question_states', 'answer', $responses, array('id'=> $state->id));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -623,9 +622,7 @@ class question_calculated_qtype extends default_questiontype {
|
|||
}
|
||||
$questionname ="#".$questionname;
|
||||
}
|
||||
if (!$DB->set_field('question', 'name', $questionname, array("id" => $question->id))) {
|
||||
return false ;
|
||||
}
|
||||
$DB->set_field('question', 'name', $questionname, array("id" => $question->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -703,9 +700,7 @@ class question_calculated_qtype extends default_questiontype {
|
|||
}else {
|
||||
$options_synchronize = 0 ;
|
||||
}
|
||||
if (!$DB->set_field('question_calculated_options', 'synchronize', $options_synchronize, array("question" => $question->id))) {
|
||||
return false;
|
||||
}
|
||||
$DB->set_field('question_calculated_options', 'synchronize', $options_synchronize, array("question" => $question->id));
|
||||
if(isset($form->synchronize) && $form->synchronize == 2 ){
|
||||
$this->addnamecategory($question);
|
||||
}
|
||||
|
|
|
@ -241,9 +241,7 @@ class question_calculatedmulti_qtype extends question_calculated_qtype {
|
|||
$responses .= implode(',', $state->responses);
|
||||
|
||||
// Set the legacy answer field
|
||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id'=> $state->id))) {
|
||||
return false;
|
||||
}
|
||||
$DB->set_field('question_states', 'answer', $responses, array('id'=> $state->id));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -230,9 +230,7 @@ class question_match_qtype extends default_questiontype {
|
|||
$responses = implode(',', $responses);
|
||||
|
||||
// Set the legacy answer field
|
||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id))) {
|
||||
return false;
|
||||
}
|
||||
$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -210,9 +210,7 @@ class embedded_cloze_qtype extends default_questiontype {
|
|||
$responses = implode(',', $responses);
|
||||
|
||||
// Set the legacy answer field
|
||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id))) {
|
||||
return false;
|
||||
}
|
||||
$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -236,9 +236,7 @@ class question_multichoice_qtype extends default_questiontype {
|
|||
$responses .= implode(',', $state->responses);
|
||||
|
||||
// Set the legacy answer field
|
||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id))) {
|
||||
return false;
|
||||
}
|
||||
$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -416,9 +416,7 @@ class question_numerical_qtype extends question_shortanswer_qtype {
|
|||
$responses = $state->responses['answer'].'|||||';
|
||||
}
|
||||
// Set the legacy answer field
|
||||
if (!$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id))) {
|
||||
return false;
|
||||
}
|
||||
$DB->set_field('question_states', 'answer', $responses, array('id' => $state->id));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -297,8 +297,7 @@ class random_qtype extends default_questiontype {
|
|||
$response = "random$realqid-$response";
|
||||
|
||||
// ... 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
|
||||
$wrappedquestion->id = $realqid;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue