mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
"MDL-14129, fix print_error"
This commit is contained in:
parent
d5edb9614e
commit
0b4f4187a2
5 changed files with 31 additions and 32 deletions
|
@ -247,7 +247,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
|
||||||
if ( $todo=='create'){
|
if ( $todo=='create'){
|
||||||
if (!$datasetdef->id = insert_record(
|
if (!$datasetdef->id = insert_record(
|
||||||
'question_dataset_definitions', $datasetdef)) {
|
'question_dataset_definitions', $datasetdef)) {
|
||||||
print_error("Unable to create dataset $defid");
|
print_error('cannotcreatedataset', 'question', '', $defid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Create relation to the dataset:
|
// Create relation to the dataset:
|
||||||
|
@ -256,7 +256,8 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
|
||||||
$questiondataset->datasetdefinition = $datasetdef->id;
|
$questiondataset->datasetdefinition = $datasetdef->id;
|
||||||
if (!insert_record('question_datasets',
|
if (!insert_record('question_datasets',
|
||||||
$questiondataset)) {
|
$questiondataset)) {
|
||||||
print_error("Unable to create relation to dataset $dataset->name $todo");
|
print_error("cannotcreaterelation", 'question', '',
|
||||||
|
array($dataset->name, $todo));
|
||||||
}
|
}
|
||||||
if ($todo=='create'){ // add the items
|
if ($todo=='create'){ // add the items
|
||||||
foreach ($dataset->datasetitem as $dataitem ){
|
foreach ($dataset->datasetitem as $dataitem ){
|
||||||
|
@ -265,7 +266,8 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
|
||||||
$datasetitem->itemnumber = $dataitem->itemnumber ;
|
$datasetitem->itemnumber = $dataitem->itemnumber ;
|
||||||
$datasetitem->value = $dataitem->value ;
|
$datasetitem->value = $dataitem->value ;
|
||||||
if (!insert_record('question_dataset_items', $datasetitem)) {
|
if (!insert_record('question_dataset_items', $datasetitem)) {
|
||||||
print_error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name");
|
print_error('cannotinsertitem', 'question', '',
|
||||||
|
array($item->itemnumber, $item->value, $datasetdef->name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -623,11 +625,11 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
|
||||||
// Reuse any previously used record
|
// Reuse any previously used record
|
||||||
$addeditem->id = $fromform->itemid[$i];
|
$addeditem->id = $fromform->itemid[$i];
|
||||||
if (!update_record('question_dataset_items', $addeditem)) {
|
if (!update_record('question_dataset_items', $addeditem)) {
|
||||||
print_error("Error: Unable to update dataset item");
|
print_error('cannotupdateitem', 'question');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!insert_record('question_dataset_items', $addeditem)) {
|
if (!insert_record('question_dataset_items', $addeditem)) {
|
||||||
print_error("Error: Unable to insert dataset item");
|
print_error('cannotinsert', 'question');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,7 +676,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
|
||||||
}
|
}
|
||||||
//pp echo "<pre>"; print_r( $datasetitem );
|
//pp echo "<pre>"; print_r( $datasetitem );
|
||||||
if (!insert_record('question_dataset_items', $datasetitem)) {
|
if (!insert_record('question_dataset_items', $datasetitem)) {
|
||||||
print_error("Error: Unable to insert new dataset item");
|
print_error('cannotinsert', 'question');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//for number added
|
}//for number added
|
||||||
|
@ -698,7 +700,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
|
||||||
$datasetdef->itemcount= $newmaxnumber ;
|
$datasetdef->itemcount= $newmaxnumber ;
|
||||||
if (!update_record('question_dataset_definitions',
|
if (!update_record('question_dataset_definitions',
|
||||||
$datasetdef)) {
|
$datasetdef)) {
|
||||||
print_error("Error: Unable to update itemcount");
|
print_error('cannotupdatecount', 'question');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -720,7 +722,7 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype
|
||||||
return sprintf("%.".$regs[4]."f",$nbr);
|
return sprintf("%.".$regs[4]."f",$nbr);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
print_error("The distribution $regs[1] caused problems");
|
print_error('disterror', 'question', '', $regs[1]);
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
{$CFG->prefix}question_datasets b
|
{$CFG->prefix}question_datasets b
|
||||||
WHERE b.question = $question->id
|
WHERE b.question = $question->id
|
||||||
AND a.id = b.datasetdefinition")) {
|
AND a.id = b.datasetdefinition")) {
|
||||||
print_error("Couldn't get the specified dataset for a calculated " .
|
print_error('cannotgetdsforquestion', 'question', '', $question->id);
|
||||||
"question! (question: {$question->id}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choose a random dataset
|
// Choose a random dataset
|
||||||
|
@ -131,7 +130,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
require("$CFG->dirroot/question/type/datasetdependent/datasetitems.php");
|
require("$CFG->dirroot/question/type/datasetdependent/datasetitems.php");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print_error('Incorrect or no wizard page specified!');
|
print_error('invalidwizardpage', 'question');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,7 +159,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
$mform =& new question_dataset_dependent_items_form("$submiturl?wizardnow=datasetitems", $question, $regenerate);
|
$mform =& new question_dataset_dependent_items_form("$submiturl?wizardnow=datasetitems", $question, $regenerate);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print_error('Incorrect or no wizard page specified!');
|
print_error('invalidwizardpage', 'question');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +312,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
$this->save_dataset_items($question, $form);
|
$this->save_dataset_items($question, $form);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print_error('Incorrect or no wizard page specified!');
|
print_error('invalidwizardpage', 'question');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $question;
|
return $question;
|
||||||
|
@ -388,7 +387,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
|
|
||||||
if (!$datasetdef->id = insert_record(
|
if (!$datasetdef->id = insert_record(
|
||||||
'question_dataset_definitions', $datasetdef)) {
|
'question_dataset_definitions', $datasetdef)) {
|
||||||
print_error("Unable to create dataset $defid");
|
print_error("cannotcreatedataset", 'question', '', $defid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != $datasetdef->category) {
|
if (0 != $datasetdef->category) {
|
||||||
|
@ -419,7 +418,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
$questiondataset->datasetdefinition = $datasetdef->id;
|
$questiondataset->datasetdefinition = $datasetdef->id;
|
||||||
if (!insert_record('question_datasets',
|
if (!insert_record('question_datasets',
|
||||||
$questiondataset)) {
|
$questiondataset)) {
|
||||||
print_error("Unable to create relation to dataset $name");
|
print_error('cannotcreaterelation', 'question', '', $name);
|
||||||
}
|
}
|
||||||
unset($datasetdefinitions[$defid]);
|
unset($datasetdefinitions[$defid]);
|
||||||
}
|
}
|
||||||
|
@ -468,7 +467,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
$datasetdef->itemcount =0;
|
$datasetdef->itemcount =0;
|
||||||
if (!$datasetdef->id = insert_record(
|
if (!$datasetdef->id = insert_record(
|
||||||
'question_dataset_definitions', $datasetdef)) {
|
'question_dataset_definitions', $datasetdef)) {
|
||||||
print_error("Unable to create dataset $defid");
|
print_error('cannotcreatedataset', 'question', '', $defid);
|
||||||
}
|
}
|
||||||
//copy the dataitems
|
//copy the dataitems
|
||||||
$olditems = get_records_sql( // Use number as key!!
|
$olditems = get_records_sql( // Use number as key!!
|
||||||
|
@ -480,7 +479,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
foreach($olditems as $item ){
|
foreach($olditems as $item ){
|
||||||
$item->definition = $datasetdef->id;
|
$item->definition = $datasetdef->id;
|
||||||
if (!insert_record('question_dataset_items', $item)) {
|
if (!insert_record('question_dataset_items', $item)) {
|
||||||
print_error("Unable to insert dataset item $item->itemnumber with $item->value for $datasetdef->name");
|
print_error('cannotinsertitem', 'question', '', array($item->itemnumber, $item->value, $datasetdef->name));
|
||||||
}
|
}
|
||||||
$itemcount++;
|
$itemcount++;
|
||||||
}
|
}
|
||||||
|
@ -496,7 +495,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
$questiondataset->datasetdefinition = $datasetdef->id;
|
$questiondataset->datasetdefinition = $datasetdef->id;
|
||||||
if (!insert_record('question_datasets',
|
if (!insert_record('question_datasets',
|
||||||
$questiondataset)) {
|
$questiondataset)) {
|
||||||
print_error("Unable to create relation to dataset $name");
|
print_error('cannotcreaterelation', 'question', '', $name);
|
||||||
}
|
}
|
||||||
unset($datasetdefinitions[$defid]);
|
unset($datasetdefinitions[$defid]);
|
||||||
continue;
|
continue;
|
||||||
|
@ -504,7 +503,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
// really new one code similar to save_dataset_definitions()
|
// really new one code similar to save_dataset_definitions()
|
||||||
if (!$datasetdef->id = insert_record(
|
if (!$datasetdef->id = insert_record(
|
||||||
'question_dataset_definitions', $datasetdef)) {
|
'question_dataset_definitions', $datasetdef)) {
|
||||||
print_error("Unable to create dataset $defid");
|
print_error('cannotcreatedataset', 'question', '', $defid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != $datasetdef->category) {
|
if (0 != $datasetdef->category) {
|
||||||
|
@ -535,7 +534,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
$questiondataset->datasetdefinition = $datasetdef->id;
|
$questiondataset->datasetdefinition = $datasetdef->id;
|
||||||
if (!insert_record('question_datasets',
|
if (!insert_record('question_datasets',
|
||||||
$questiondataset)) {
|
$questiondataset)) {
|
||||||
print_error("Unable to create relation to dataset $name");
|
print_error('cannotcreaterelation', 'question', '', $name);
|
||||||
}
|
}
|
||||||
unset($datasetdefinitions[$defid]);
|
unset($datasetdefinitions[$defid]);
|
||||||
}
|
}
|
||||||
|
@ -608,7 +607,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print_error('Incorrect or no wizard page specified!');
|
print_error('invalidwizardpage', 'question');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $question;
|
return $question;
|
||||||
|
@ -633,16 +632,14 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
AND q.datasetdefinition = d.id
|
AND q.datasetdefinition = d.id
|
||||||
AND d.id = i.definition
|
AND d.id = i.definition
|
||||||
AND i.itemnumber = $datasetitem")) {
|
AND i.itemnumber = $datasetitem")) {
|
||||||
print_error("Couldn't get the specified dataset for a dataset dependent " .
|
print_error('cannotgetdsfordependent', 'question', '', array($question->id, $datasetitem));
|
||||||
"question! (question: {$question->id}, " .
|
|
||||||
"datasetitem: {$datasetitem})");
|
|
||||||
}
|
}
|
||||||
array_walk($dataset, create_function('&$val', '$val = $val->value;'));
|
array_walk($dataset, create_function('&$val', '$val = $val->value;'));
|
||||||
return $dataset;
|
return $dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_virtual_qtype() {
|
function create_virtual_qtype() {
|
||||||
print_error("No virtual question type for question type ".$this->name());
|
print_error("novirtualquestion", 'question', '', $this->name());
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_virtual_qtype() {
|
function get_virtual_qtype() {
|
||||||
|
@ -757,7 +754,7 @@ class question_dataset_dependent_questiontype extends default_questiontype {
|
||||||
|
|
||||||
function create_virtual_nameprefix($nameprefix, $datasetinput) {
|
function create_virtual_nameprefix($nameprefix, $datasetinput) {
|
||||||
if (!ereg('([0-9]+)' . $this->name() . '$', $nameprefix, $regs)) {
|
if (!ereg('([0-9]+)' . $this->name() . '$', $nameprefix, $regs)) {
|
||||||
print_error("Wrongly formatted nameprefix $nameprefix");
|
print_error('wrongprefix', 'question', '', $nameprefix);
|
||||||
}
|
}
|
||||||
$virtualqtype = $this->get_virtual_qtype();
|
$virtualqtype = $this->get_virtual_qtype();
|
||||||
return $nameprefix . $regs[1] . $virtualqtype->name();
|
return $nameprefix . $regs[1] . $virtualqtype->name();
|
||||||
|
|
|
@ -51,7 +51,7 @@ class description_qtype extends default_questiontype {
|
||||||
} else if (!empty($cmoptions->course)) {
|
} else if (!empty($cmoptions->course)) {
|
||||||
$cmorcourseid = '&courseid='.$cmoptions->course;
|
$cmorcourseid = '&courseid='.$cmoptions->course;
|
||||||
} else {
|
} else {
|
||||||
print_error('Need to provide courseid or cmid to print_question.');
|
print_error('missingcourseorcmid', 'question');
|
||||||
}
|
}
|
||||||
|
|
||||||
// For editing teachers print a link to an editing popup window
|
// For editing teachers print a link to an editing popup window
|
||||||
|
|
|
@ -344,7 +344,7 @@ class question_numerical_qtype extends question_shortanswer_qtype {
|
||||||
$min = $answer->answer / $quotient;
|
$min = $answer->answer / $quotient;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print_error("Unknown tolerance type $answer->tolerancetype");
|
print_error('unknowntolerance', 'question', '', $answer->tolerancetype);
|
||||||
}
|
}
|
||||||
|
|
||||||
$answer->min = $min;
|
$answer->min = $min;
|
||||||
|
|
|
@ -282,7 +282,7 @@ class default_questiontype {
|
||||||
$question->modifiedby = $USER->id;
|
$question->modifiedby = $USER->id;
|
||||||
$question->timemodified = time();
|
$question->timemodified = time();
|
||||||
if (!update_record('question', $question)) {
|
if (!update_record('question', $question)) {
|
||||||
print_error('Could not update question!');
|
print_error('cannotupdatequestion', 'question');
|
||||||
}
|
}
|
||||||
} else { // Question is a new one
|
} else { // Question is a new one
|
||||||
if (isset($form->categorymoveto)){
|
if (isset($form->categorymoveto)){
|
||||||
|
@ -302,7 +302,7 @@ class default_questiontype {
|
||||||
$question->timecreated = time();
|
$question->timecreated = time();
|
||||||
$question->timemodified = time();
|
$question->timemodified = time();
|
||||||
if (!$question->id = insert_record('question', $question)) {
|
if (!$question->id = insert_record('question', $question)) {
|
||||||
print_error('Could not insert new question!');
|
print_error('cannotinsertquestion', 'question');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ class default_questiontype {
|
||||||
|
|
||||||
// Give the question a unique version stamp determined by question_hash()
|
// Give the question a unique version stamp determined by question_hash()
|
||||||
if (!set_field('question', 'version', question_hash($question), 'id', $question->id)) {
|
if (!set_field('question', 'version', question_hash($question), 'id', $question->id)) {
|
||||||
print_error('Could not update question version field');
|
print_error('cannotupdatequestionver', 'question');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $question;
|
return $question;
|
||||||
|
@ -824,7 +824,7 @@ class default_questiontype {
|
||||||
$context = get_context_instance(CONTEXT_COURSE, $cmoptions->course);
|
$context = get_context_instance(CONTEXT_COURSE, $cmoptions->course);
|
||||||
$cmorcourseid = '&courseid='.$cmoptions->course;
|
$cmorcourseid = '&courseid='.$cmoptions->course;
|
||||||
} else {
|
} else {
|
||||||
print_error('Need to provide courseid or cmid to print_question.');
|
print_error('missingcourseorcmid', 'question');
|
||||||
}
|
}
|
||||||
|
|
||||||
// For editing teachers print a link to an editing popup window
|
// For editing teachers print a link to an editing popup window
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue