mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-18293 removed obsoleted checking of return values from insert and update_record + unused strings cleanup
This commit is contained in:
parent
a8c31db2a3
commit
0bcf8b6f0d
10 changed files with 21 additions and 83 deletions
|
@ -163,15 +163,9 @@ class question_calculated_qtype extends default_questiontype {
|
|||
|
||||
if ($oldanswer = array_shift($oldanswers)) { // Existing answer, so reuse it
|
||||
$answer->id = $oldanswer->id;
|
||||
if (! $DB->update_record("question_answers", $answer)) {
|
||||
$result->error = get_string('errorupdatinganswer','question',$answer->id);
|
||||
return $result;
|
||||
}
|
||||
$DB->update_record("question_answers", $answer);
|
||||
} else { // This is a completely new answer
|
||||
if (! $answer->id = $DB->insert_record("question_answers", $answer)) {
|
||||
$result->error = get_string('errorinsertinganswer','question');
|
||||
return $result;
|
||||
}
|
||||
$answer->id = $DB->insert_record("question_answers", $answer);
|
||||
}
|
||||
|
||||
// Set up the options object
|
||||
|
@ -187,18 +181,9 @@ class question_calculated_qtype extends default_questiontype {
|
|||
|
||||
// Save options
|
||||
if (isset($options->id)) { // reusing existing record
|
||||
if (! $DB->update_record('question_calculated', $options)) {
|
||||
$mess->name = $this->name();
|
||||
$mess->id = $options->id ;
|
||||
$result->error = get_string('errorupdatingoptions','question',$mess);
|
||||
// $result->error = "Could not update question calculated options! (id=$options->id)";
|
||||
return $result;
|
||||
}
|
||||
$DB->update_record('question_calculated', $options);
|
||||
} else { // new options
|
||||
if (! $DB->insert_record('question_calculated', $options)) {
|
||||
$result->error = "Could not insert question calculated options!";
|
||||
return $result;
|
||||
}
|
||||
$DB->insert_record('question_calculated', $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -870,11 +855,7 @@ class question_calculated_qtype extends default_questiontype {
|
|||
$options->tolerancetype = trim($fromform->tolerancetype[$key]);
|
||||
$options->correctanswerlength = trim($fromform->correctanswerlength[$key]);
|
||||
$options->correctanswerformat = trim($fromform->correctanswerformat[$key]);
|
||||
if (! $DB->update_record('question_calculated', $options)) {
|
||||
$mess->name = $this->name();
|
||||
$mess->id = $options->id ;
|
||||
notify ( get_string('errorupdatingoptions','question',$mess));
|
||||
}
|
||||
$DB->update_record('question_calculated', $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,15 +61,9 @@ class question_calculatedsimple_qtype extends question_calculated_qtype {
|
|||
|
||||
if ($oldanswer = array_shift($oldanswers)) { // Existing answer, so reuse it
|
||||
$answer->id = $oldanswer->id;
|
||||
if (! $DB->update_record("question_answers", $answer)) {
|
||||
$result->error = get_string('errorupdatinganswer','question',$answer->id);
|
||||
return $result;
|
||||
}
|
||||
$DB->update_record("question_answers", $answer);
|
||||
} else { // This is a completely new answer
|
||||
if (! $answer->id = $DB->insert_record("question_answers", $answer)) {
|
||||
$result->error = get_string('errorinsertinganswer','question');
|
||||
return $result;
|
||||
}
|
||||
$answer->id = $DB->insert_record("question_answers", $answer);
|
||||
}
|
||||
|
||||
// Set up the options object
|
||||
|
@ -85,18 +79,9 @@ class question_calculatedsimple_qtype extends question_calculated_qtype {
|
|||
|
||||
// Save options
|
||||
if (isset($options->id)) { // reusing existing record
|
||||
if (! $DB->update_record('question_calculated', $options)) {
|
||||
$mess->name = $this->name();
|
||||
$mess->id = $options->id ;
|
||||
$result->error = get_string('errorupdatingoptions','question',$mess);
|
||||
// $result->error = "Could not update question calculated options! (id=$options->id)";
|
||||
return $result;
|
||||
}
|
||||
$DB->update_record('question_calculated', $options);
|
||||
} else { // new options
|
||||
if (! $DB->insert_record('question_calculated', $options)) {
|
||||
$result->error = "Could not insert question calculated options!";
|
||||
return $result;
|
||||
}
|
||||
$DB->insert_record('question_calculated', $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,15 +137,9 @@ class question_numerical_qtype extends question_shortanswer_qtype {
|
|||
|
||||
if ($oldanswer = array_shift($oldanswers)) { // Existing answer, so reuse it
|
||||
$answer->id = $oldanswer->id;
|
||||
if (! $DB->update_record("question_answers", $answer)) {
|
||||
$result->error = "Could not update quiz answer! (id=$answer->id)";
|
||||
return $result;
|
||||
}
|
||||
$DB->update_record("question_answers", $answer);
|
||||
} else { // This is a completely new answer
|
||||
if (! $answer->id = $DB->insert_record("question_answers", $answer)) {
|
||||
$result->error = "Could not insert quiz answer!";
|
||||
return $result;
|
||||
}
|
||||
$answer->id = $DB->insert_record("question_answers", $answer);
|
||||
}
|
||||
|
||||
// Set up the options object
|
||||
|
@ -165,15 +159,9 @@ class question_numerical_qtype extends question_shortanswer_qtype {
|
|||
|
||||
// Save options
|
||||
if (isset($options->id)) { // reusing existing record
|
||||
if (! $DB->update_record('question_numerical', $options)) {
|
||||
$result->error = "Could not update quiz numerical options! (id=$options->id)";
|
||||
return $result;
|
||||
}
|
||||
$DB->update_record('question_numerical', $options);
|
||||
} else { // new options
|
||||
if (! $DB->insert_record('question_numerical', $options)) {
|
||||
$result->error = "Could not insert quiz numerical options!";
|
||||
return $result;
|
||||
}
|
||||
$DB->insert_record('question_numerical', $options);
|
||||
}
|
||||
}
|
||||
// delete old answer records
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue