diff --git a/question/category_class.php b/question/category_class.php index cd331b828c08f..4684415fd738b 100644 --- a/question/category_class.php +++ b/question/category_class.php @@ -290,7 +290,7 @@ public function edit_single_category($categoryid) { /// Interface for editing existing categories if ($category = $DB->get_record("question_categories", array("id" => $categoryid))) { - $category->parent = "$category->parent,$category->contextid"; + $category->parent = "{$category->parent},{$category->contextid}"; $category->submitbutton = get_string('savechanges'); $category->categoryheader = $this->str->edit; $this->catform->set_data($category); diff --git a/question/classes/bank/view.php b/question/classes/bank/view.php index d4018acb5a633..579bd31453787 100644 --- a/question/classes/bank/view.php +++ b/question/classes/bank/view.php @@ -724,7 +724,7 @@ protected function display_question_list($contexts, $pageurl, $categoryandcontex array('qperpage' => DEFAULT_QUESTIONS_PER_PAGE))); $showall = ''.get_string('showperpage', 'moodle', DEFAULT_QUESTIONS_PER_PAGE).''; } - echo "
$text\n"; + echo "
{$text}\n"; } - echo "$message\n"; + echo "{$message}\n"; echo "
$count. ".$this->format_question_text($question)."
"; + echo "{$count}. ".$this->format_question_text($question)."
"; $question->category = $this->category->id; $question->stamp = make_unique_id_code(); // Set the unique code (not to be changed) @@ -691,7 +691,7 @@ protected function add_blank_combined_feedback($question) { protected function readquestion($lines) { $formatnotimplemented = get_string('formatnotimplemented', 'question'); - echo "$formatnotimplemented
"; + echo "{$formatnotimplemented}
"; return null; } @@ -719,7 +719,7 @@ public function importpostprocess() { protected function try_exporting_using_qtypes($name, $question, $extra=null) { // work out the name of format in use $formatname = substr(get_class($this), strlen('qformat_')); - $methodname = "export_to_$formatname"; + $methodname = "export_to_{$formatname}"; $qtype = question_bank::get_qtype($name, false); if (method_exists($qtype, $methodname)) { @@ -819,7 +819,7 @@ public function exportprocess() { // continue path for following error checks $course = $this->course; - $continuepath = "$CFG->wwwroot/question/export.php?courseid=$course->id"; + $continuepath = "{$CFG->wwwroot}/question/export.php?courseid={$course->id}"; // did we actually process anything if ($count==0) { @@ -924,7 +924,7 @@ protected function exportpostprocess() { protected function writequestion($question) { // if not overidden, then this is an error. $formatnotimplemented = get_string('formatnotimplemented', 'question'); - echo "$formatnotimplemented
"; + echo "{$formatnotimplemented}
"; return null; } diff --git a/question/format/blackboard_six/formatbase.php b/question/format/blackboard_six/formatbase.php index 75f6368e6eca0..5033827650a9d 100644 --- a/question/format/blackboard_six/formatbase.php +++ b/question/format/blackboard_six/formatbase.php @@ -134,7 +134,7 @@ public function text_field($text) { $dirpath = dirname($path); $filename = basename($path); $newfilename = $this->store_file_for_text_field($data, $this->filebase, $dirpath, $filename); - $text = preg_replace("|$path|", "@@PLUGINFILE@@/" . $newfilename, $text); + $text = preg_replace("|{$path}|", "@@PLUGINFILE@@/" . $newfilename, $text); $filepaths[] = $path; } diff --git a/question/format/gift/format.php b/question/format/gift/format.php index 156d4a888a0ce..5b3ca64e70370 100644 --- a/question/format/gift/format.php +++ b/question/format/gift/format.php @@ -416,7 +416,7 @@ public function readquestion($lines) { list($answer, $wrongfeedback, $rightfeedback) = $this->split_truefalse_comment($answertext, $question->questiontextformat); - if ($answer['text'] == "T" OR $answer['text'] == "TRUE") { + if ($answer['text'] == "T" || $answer['text'] == "TRUE") { $question->correctanswer = 1; $question->feedbacktrue = $rightfeedback; $question->feedbackfalse = $wrongfeedback; @@ -634,7 +634,7 @@ public function writequestion($question) { global $OUTPUT; // Start with a comment. - $expout = "// question: $question->id name: $question->name\n"; + $expout = "// question: {$question->id} name: {$question->name}\n"; // Output depends on question type. switch($question->qtype) { diff --git a/question/format/webct/format.php b/question/format/webct/format.php index 4e184bc8a397f..57c3175bff794 100644 --- a/question/format/webct/format.php +++ b/question/format/webct/format.php @@ -150,7 +150,7 @@ function qformat_webct_convert_formula($formula) { } // Replace it! - $formula = "$splits[0]pow($base,$exp)$splits[1]"; + $formula = "{$splits[0]}pow({$base},{$exp}){$splits[1]}"; } // Nothing more is known to need to be converted. @@ -239,7 +239,7 @@ public function text_field($text) { $dirpath = dirname($path); $filename = basename($path); $newfilename = $this->store_file_for_text_field($data, $this->tempdir, $dirpath, $filename); - $text = preg_replace("|$path|", "@@PLUGINFILE@@/" . $newfilename, $text); + $text = preg_replace("|{$path}|", "@@PLUGINFILE@@/" . $newfilename, $text); $filepaths[] = $path; } @@ -497,7 +497,7 @@ public function readquestions ($lines) { case 'shortanswer': if ($maxfraction != 1) { $maxfraction = $maxfraction * 100; - $errors[] = "'$question->name': ".get_string('wronggrade', 'qformat_webct', $nlinecounter) + $errors[] = "'{$question->name}': ".get_string('wronggrade', 'qformat_webct', $nlinecounter) .' '.get_string('fractionsnomax', 'question', $maxfraction); $questionok = false; } @@ -509,7 +509,7 @@ public function readquestions ($lines) { if ($question->single) { if ($maxfraction != 1) { $maxfraction = $maxfraction * 100; - $errors[] = "'$question->name': ".get_string('wronggrade', 'qformat_webct', $nlinecounter) + $errors[] = "'{$question->name}': ".get_string('wronggrade', 'qformat_webct', $nlinecounter) .' '.get_string('fractionsnomax', 'question', $maxfraction); $questionok = false; } @@ -517,7 +517,7 @@ public function readquestions ($lines) { $totalfraction = round($totalfraction, 2); if ($totalfraction != 1) { $totalfraction = $totalfraction * 100; - $errors[] = "'$question->name': ".get_string('wronggrade', 'qformat_webct', $nlinecounter) + $errors[] = "'{$question->name}': ".get_string('wronggrade', 'qformat_webct', $nlinecounter) .' '.get_string('fractionsaddwrong', 'question', $totalfraction); $questionok = false; } @@ -527,7 +527,7 @@ public function readquestions ($lines) { case 'calculated': foreach ($question->answers as $answer) { if ($formulaerror = qtype_calculated_find_formula_errors($answer)) { - $warnings[] = "'$question->name': ". $formulaerror; + $warnings[] = "'{$question->name}': ". $formulaerror; $questionok = false; } } @@ -687,7 +687,7 @@ public function readquestions ($lines) { continue; } if (isset($question->qtype ) && 'calculated' == $question->qtype && preg_match( - "~^:([[:lower:]].*|::.*)-(MIN|MAX|DEC|VAL([0-9]+))::?:?($webctnumberregex)~", $line, $webctoptions)) { + "~^:([[:lower:]].*|::.*)-(MIN|MAX|DEC|VAL([0-9]+))::?:?({$webctnumberregex})~", $line, $webctoptions)) { $datasetname = preg_replace('/^::/', '', $webctoptions[1]); $datasetvalue = qformat_webct_convert_formula($webctoptions[4]); switch ($webctoptions[2]) { @@ -803,7 +803,7 @@ public function readquestions ($lines) { } if (isset($question->qtype )&& 'calculated' == $question->qtype - && preg_match("~^:TOL:($webctnumberregex)~i", $line, $webctoptions)) { + && preg_match("~^:TOL:({$webctnumberregex})~i", $line, $webctoptions)) { // We can but hope that this always appear before the TOL property. $question->tolerance[$currentchoice] = qformat_webct_convert_formula($webctoptions[1]); @@ -858,7 +858,7 @@ public function readquestions ($lines) { if (count($errors) > 0) { echo ''.get_string('errorsdetected', 'qformat_webct', count($errors)).'
'.get_string('warningsdetected', 'qformat_webct', count($warnings)).'
$namestr | + scope=\"col\">{$namestr}$rangeofvaluestr | + scope=\"col\">{$rangeofvaluestr}$itemscountstr | + scope=\"col\">{$itemscountstr}$questionusingstr | + scope=\"col\">{$questionusingstr}||||
---|---|---|---|---|---|---|---|
$datasetdef->name | -$min - $max | -$datasetdef->itemcount | +{$datasetdef->name} | +{$min} - $max | +{$datasetdef->itemcount} | ";
foreach ($datasetdef->questions as $qu) {
// Limit the name length displayed.
@@ -1618,7 +1618,7 @@ public function print_dataset_definitions_category($form) {
} else {
$qu->name = '';
}
- $text .= " $qu->name "; + $text .= " {$qu->name} "; } $text .= " |
$namestr | "; + scope=\"col\">{$namestr}"; $text .= "$itemscountstr | "; + scope=\"col\">{$itemscountstr}"; $text .= "$questionusingstr | "; + scope=\"col\"> {$questionusingstr} "; $text .= "Quiz | "; $text .= "questions); $text .= " | |||
---|---|---|---|---|---|---|---|
$datasetdef->name | + align=\"center\" rowspan=\"{$count}\"> {$datasetdef->name}$datasetdef->itemcount | "; + rowspan=\"{$count}\">{$datasetdef->itemcount}"; $line = 0; foreach ($datasetdef->questions as $qu) { // Limit the name length displayed. @@ -1704,7 +1704,7 @@ public function print_dataset_definitions_category_shared($question, $datasetdef $text .= "||||||
$qu->name | "; + $text .= "{$qu->name} | "; // TODO MDL-43779 should not have quiz-specific code here. $nbofquiz = $DB->count_records('quiz_slots', array('questionid' => $qu->id)); $nbofattempts = $DB->count_records_sql(" @@ -1714,8 +1714,8 @@ public function print_dataset_definitions_category_shared($question, $datasetdef WHERE slot.questionid = ? AND quiza.preview = 0", array($qu->id)); if ($nbofquiz > 0) { - $text .= "$nbofquiz | "; - $text .= "$nbofattempts"; + $text .= " | {$nbofquiz} | "; + $text .= "{$nbofattempts}"; } else { $text .= " | 0 | "; $text .= ""; @@ -1866,8 +1866,8 @@ function qtype_calculated_calculate_answer($formula, $individualdata, } } else { // Stick to plain numeric format. - $answer *= "1e$p10"; - if (0.1 <= $answer / "1e$answerlength") { + $answer *= "1e{$p10}"; + if (0.1 <= $answer / "1e{$answerlength}") { $calculated->answer = $sign.$answer; } else { // Could be an idea to add some zeros here. @@ -1903,11 +1903,11 @@ function qtype_calculated_find_formula_errors($formula) { $formula = strtolower(str_replace(' ', '', $formula)); $safeoperatorchar = '-+/*%>:^\~=&|!'; /* */ - $operatorornumber = "[$safeoperatorchar.0-9eE]"; + $operatorornumber = "[{$safeoperatorchar}.0-9eE]"; - while (preg_match("~(^|[$safeoperatorchar,(])([a-z0-9_]*)" . - "\\(($operatorornumber+(,$operatorornumber+((,$operatorornumber+)+)?)?)?\\)~", - $formula, $regs)) { + while (preg_match("~(^|[{$safeoperatorchar},(])([a-z0-9_]*)" . + "\\(({$operatorornumber}+(,{$operatorornumber}+((,{$operatorornumber}+)+)?)?)?\\)~", + $formula, $regs)) { switch ($regs[2]) { // Simple parenthesis. case '': @@ -1968,11 +1968,11 @@ function qtype_calculated_find_formula_errors($formula) { $formula = str_replace($regs[0], $regs[1] . '1', $formula); } else { // The function call starts the formula. - $formula = preg_replace("~^$regs[2]\\([^)]*\\)~", '1', $formula); + $formula = preg_replace("~^{$regs[2]}\\([^)]*\\)~", '1', $formula); } } - if (preg_match("~[^$safeoperatorchar.0-9eE]+~", $formula, $regs)) { + if (preg_match("~[^{$safeoperatorchar}.0-9eE]+~", $formula, $regs)) { return get_string('illegalformulasyntax', 'qtype_calculated', $regs[0]); } else { // Formula just might be valid. diff --git a/question/type/calculatedmulti/edit_calculatedmulti_form.php b/question/type/calculatedmulti/edit_calculatedmulti_form.php index 400a1dfad6df7..e18d9894a6001 100644 --- a/question/type/calculatedmulti/edit_calculatedmulti_form.php +++ b/question/type/calculatedmulti/edit_calculatedmulti_form.php @@ -167,12 +167,12 @@ protected function definition_inner($mform) { $mform->setType('nounits', PARAM_INT); $mform->setConstants(array('nounits'=>$nounits)); for ($i = 0; $i < $nounits; $i++) { - $mform->addElement('hidden', 'unit'."[$i]", - optional_param("unit[$i]", '', PARAM_NOTAGS)); - $mform->setType('unit'."[$i]", PARAM_NOTAGS); - $mform->addElement('hidden', 'multiplier'."[$i]", - optional_param("multiplier[$i]", '', PARAM_FLOAT)); - $mform->setType("multiplier[$i]", PARAM_FLOAT); + $mform->addElement('hidden', 'unit'."[{$i}]", + optional_param("unit[{$i}]", '', PARAM_NOTAGS)); + $mform->setType('unit'."[{$i}]", PARAM_NOTAGS); + $mform->addElement('hidden', 'multiplier'."[{$i}]", + optional_param("multiplier[{$i}]", '', PARAM_FLOAT)); + $mform->setType("multiplier[{$i}]", PARAM_FLOAT); } $this->add_combined_feedback_fields(true); @@ -217,10 +217,10 @@ protected function data_preprocessing_answers($question, $withanswerfiles = fals $key = 0; foreach ($question->options->answers as $answer) { // See comment in the parent method about this hack. - unset($this->_form->_defaultValues["tolerance[$key]"]); - unset($this->_form->_defaultValues["tolerancetype[$key]"]); - unset($this->_form->_defaultValues["correctanswerlength[$key]"]); - unset($this->_form->_defaultValues["correctanswerformat[$key]"]); + unset($this->_form->_defaultValues["tolerance[{$key}]"]); + unset($this->_form->_defaultValues["tolerancetype[{$key}]"]); + unset($this->_form->_defaultValues["correctanswerlength[{$key}]"]); + unset($this->_form->_defaultValues["correctanswerformat[{$key}]"]); $question->tolerance[$key] = $answer->tolerance; $question->tolerancetype[$key] = $answer->tolerancetype; diff --git a/question/type/calculatedsimple/edit_calculatedsimple_form.php b/question/type/calculatedsimple/edit_calculatedsimple_form.php index 87f6c80ea4eaf..54fb4f49e9394 100644 --- a/question/type/calculatedsimple/edit_calculatedsimple_form.php +++ b/question/type/calculatedsimple/edit_calculatedsimple_form.php @@ -202,8 +202,8 @@ public function __construct($submiturl, $question, $category, $contexts, $formed // Detect new datasets. $newdataset = false; foreach ($mandatorydatasets as $datasetname) { - if (!isset($this->datasetdefs["1-0-$datasetname"])) { - $key = "1-0-$datasetname"; + if (!isset($this->datasetdefs["1-0-{$datasetname}"])) { + $key = "1-0-{$datasetname}"; $this->datasetdefs[$key] = new stdClass(); $this->datasetdefs[$key]->type = 1; $this->datasetdefs[$key]->category = 0; @@ -211,7 +211,7 @@ public function __construct($submiturl, $question, $category, $contexts, $formed $this->datasetdefs[$key]->options = "uniform:1.0:10.0:1"; $newdataset = true; } else { - $this->datasetdefs["1-0-$datasetname"]->name = $datasetname; + $this->datasetdefs["1-0-{$datasetname}"]->name = $datasetname; } } // Remove obsolete datasets. @@ -332,15 +332,15 @@ protected function definition_inner($mform) { if (!empty($this->datasetdefs)) {// Unnecessary test. $j = (($this->noofitems) * count($this->datasetdefs))+1;// foreach ($this->datasetdefs as $defkey => $datasetdef) { - $mform->addElement('static', "na[$j]", + $mform->addElement('static', "na[{$j}]", get_string('param', 'qtype_calculated', $datasetdef->name)); $this->qtypeobj->custom_generator_tools_part($mform, $idx, $j); - $mform->addElement('hidden', "datasetdef[$idx]"); - $mform->setType("datasetdef[$idx]", PARAM_RAW); - $mform->addElement('hidden', "defoptions[$idx]"); - $mform->setType("defoptions[$idx]", PARAM_RAW); + $mform->addElement('hidden', "datasetdef[{$idx}]"); + $mform->setType("datasetdef[{$idx}]", PARAM_RAW); + $mform->addElement('hidden', "defoptions[{$idx}]"); + $mform->setType("defoptions[{$idx}]", PARAM_RAW); $idx++; - $mform->addElement('static', "divider[$j]", '', ' '); + $mform->addElement('static', "divider[{$j}]", '', ' '); $j++; } } @@ -362,23 +362,23 @@ protected function definition_inner($mform) { foreach ($this->datasetdefs as $defid => $datasetdef) { if (isset($datasetdef->items[$itemnumber])) { - $this->formdata["definition[$j]"] = $defid; - $this->formdata["itemid[$j]"] = + $this->formdata["definition[{$j}]"] = $defid; + $this->formdata["itemid[{$j}]"] = $datasetdef->items[$itemnumber]->id; $data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value; - $this->formdata["number[$j]"] = $number = + $this->formdata["number[{$j}]"] = $number = $datasetdef->items[$itemnumber]->value; if (! is_numeric($number)) { $a = new stdClass(); $a->name = '{'.$datasetdef->name.'}'; $a->value = $datasetdef->items[$itemnumber]->value; if (stristr($number, ',')) { - $this->numbererrors["number[$j]"] = + $this->numbererrors["number[{$j}]"] = get_string('nocommaallowed', 'qtype_calculated'); $numbererrors .= $this->numbererrors['number['.$j.']']." "; } else { - $this->numbererrors["number[$j]"] = + $this->numbererrors["number[{$j}]"] = get_string('notvalidnumber', 'qtype_calculated', $a); $numbererrors .= $this->numbererrors['number['.$j.']']." "; } @@ -393,7 +393,7 @@ protected function definition_inner($mform) { $a = new stdClass(); $a->name = '{'.$datasetdef->name.'}'; $a->value = $datasetdef->items[$itemnumber]->value; - $this->numbererrors["number[$j]"] = + $this->numbererrors["number[{$j}]"] = get_string('notvalidnumber', 'qtype_calculated', $a); $numbererrors .= $this->numbererrors['number['.$j.']']." "; } @@ -430,7 +430,7 @@ protected function definition_inner($mform) { $data = array(); // Data for comment_on_datasetitems later. $idx = 1; foreach ($this->datasetdefs as $defid => $datasetdef) { - $this->formdata["datasetdef[$idx]"] = $defid; + $this->formdata["datasetdef[{$idx}]"] = $defid; $idx++; } $this->formdata = $this->qtypeobj->custom_generator_set_data( @@ -440,14 +440,14 @@ protected function definition_inner($mform) { $addoptions = Array(); $addoptions['1'] = '1'; for ($i = 10; $i <= 100; $i += 10) { - $addoptions["$i"] = "$i"; + $addoptions["{$i}"] = "{$i}"; } $showoptions = Array(); $showoptions['1'] = '1'; $showoptions['2'] = '2'; $showoptions['5'] = '5'; for ($i = 10; $i <= 100; $i += 10) { - $showoptions["$i"] = "$i"; + $showoptions["{$i}"] = "{$i}"; } $mform->closeHeaderBefore('additemhdr'); $addgrp = array(); @@ -495,38 +495,38 @@ protected function definition_inner($mform) { for ($i = $this->noofitems; $i >= 1; $i--) { foreach ($this->datasetdefs as $defkey => $datasetdef) { if ($k > 0 || $this->outsidelimit || !empty($this->numbererrors)) { - $mform->addElement('text', "number[$j]", get_string( + $mform->addElement('text', "number[{$j}]", get_string( 'wildcard', 'qtype_calculatedsimple', $datasetdef->name)); - $mform->setAdvanced("number[$j]", true); + $mform->setAdvanced("number[{$j}]", true); if (!empty($this->numbererrors['number['.$j.']'])) { - $mform->addElement('static', "numbercomment[$j]", '', + $mform->addElement('static', "numbercomment[{$j}]", '', '' . $this->numbererrors['number['.$j.']'] . ''); - $mform->setAdvanced("numbercomment[$j]", true); + $mform->setAdvanced("numbercomment[{$j}]", true); } } else { - $mform->addElement('hidden', "number[$j]", get_string( + $mform->addElement('hidden', "number[{$j}]", get_string( 'wildcard', 'qtype_calculatedsimple', $datasetdef->name)); } - $mform->setType("number[$j]", PARAM_RAW); // This parameter will be validated in validation(). + $mform->setType("number[{$j}]", PARAM_RAW); // This parameter will be validated in validation(). - $mform->addElement('hidden', "itemid[$j]"); - $mform->setType("itemid[$j]", PARAM_INT); + $mform->addElement('hidden', "itemid[{$j}]"); + $mform->setType("itemid[{$j}]", PARAM_INT); - $mform->addElement('hidden', "definition[$j]"); - $mform->setType("definition[$j]", PARAM_NOTAGS); + $mform->addElement('hidden', "definition[{$j}]"); + $mform->setType("definition[{$j}]", PARAM_NOTAGS); $j--; } if (!empty($strquestionlabel) && ($k > 0 || $this->outsidelimit || !empty($this->numbererrors))) { - $mform->addElement('static', "answercomment[$i]", "" . + $mform->addElement('static', "answercomment[{$i}]", "" . get_string('setno', 'qtype_calculatedsimple', $i) . " " . $strquestionlabel); } if ($k > 0 || $this->outsidelimit || !empty($this->numbererrors)) { - $mform->addElement('static', "divider1[$j]", '', ' '); + $mform->addElement('static', "divider1[{$j}]", '', ' '); } $k--; diff --git a/question/type/calculatedsimple/questiontype.php b/question/type/calculatedsimple/questiontype.php index 8a0a264568dcd..a58a172447455 100644 --- a/question/type/calculatedsimple/questiontype.php +++ b/question/type/calculatedsimple/questiontype.php @@ -243,23 +243,23 @@ public function wizard_pages_number() { public function custom_generator_tools_part($mform, $idx, $j) { $minmaxgrp = array(); - $minmaxgrp[] = $mform->createElement('text', "calcmin[$idx]", + $minmaxgrp[] = $mform->createElement('text', "calcmin[{$idx}]", get_string('calcmin', 'qtype_calculated')); - $minmaxgrp[] = $mform->createElement('text', "calcmax[$idx]", + $minmaxgrp[] = $mform->createElement('text', "calcmax[{$idx}]", get_string('calcmax', 'qtype_calculated')); $mform->addGroup($minmaxgrp, 'minmaxgrp', get_string('minmax', 'qtype_calculated'), ' - ', false); - $mform->setType("calcmin[$idx]", PARAM_FLOAT); - $mform->setType("calcmax[$idx]", PARAM_FLOAT); + $mform->setType("calcmin[{$idx}]", PARAM_FLOAT); + $mform->setType("calcmax[{$idx}]", PARAM_FLOAT); $precisionoptions = range(0, 10); - $mform->addElement('select', "calclength[$idx]", + $mform->addElement('select', "calclength[{$idx}]", get_string('calclength', 'qtype_calculated'), $precisionoptions); $distriboptions = array('uniform' => get_string('uniform', 'qtype_calculated'), 'loguniform' => get_string('loguniform', 'qtype_calculated')); - $mform->addElement('hidden', "calcdistribution[$idx]", 'uniform'); - $mform->setType("calcdistribution[$idx]", PARAM_INT); + $mform->addElement('hidden', "calcdistribution[{$idx}]", 'uniform'); + $mform->setType("calcdistribution[{$idx}]", PARAM_INT); } public function comment_header($answers) { @@ -296,7 +296,7 @@ public function dataset_options($form, $name, $mandatory = true, $renameabledata } if (!$selected) { if ($mandatory) { - $selected = "1-0-$name"; // Default. + $selected = "1-0-{$name}"; // Default. } else { $selected = "0"; // Default. } diff --git a/question/type/edit_question_form.php b/question/type/edit_question_form.php index 16058ad8c09a5..147e4f8b160e4 100644 --- a/question/type/edit_question_form.php +++ b/question/type/edit_question_form.php @@ -124,7 +124,7 @@ protected function definition() { global $COURSE, $CFG, $DB, $PAGE; $qtype = $this->qtype(); - $langfile = "qtype_$qtype"; + $langfile = "qtype_{$qtype}"; $mform = $this->_form; @@ -418,7 +418,7 @@ protected function add_interactive_settings($withclearwrong = false, } $penaltyoptions = array(); foreach ($penalties as $penalty) { - $penaltyoptions["$penalty"] = (100 * $penalty) . '%'; + $penaltyoptions["{$penalty}"] = (100 * $penalty) . '%'; } $mform->addElement('select', 'penalty', get_string('penaltyforeachincorrecttry', 'question'), $penaltyoptions); @@ -560,7 +560,7 @@ protected function data_preprocessing_answers($question, $withanswerfiles = fals // are using object notation here, so we will be setting // ->_defaultValues['fraction'][0]. That does not work, so we have // to unset ->_defaultValues['fraction[0]']. - unset($this->_form->_defaultValues["fraction[$key]"]); + unset($this->_form->_defaultValues["fraction[{$key}]"]); // Prepare the feedback editor to display files in draft area. $draftitemid = file_get_submitted_draft_itemid('feedback['.$key.']'); diff --git a/question/type/essay/db/upgrade.php b/question/type/essay/db/upgrade.php index e473ae78f72e3..ee8e8bcff502b 100644 --- a/question/type/essay/db/upgrade.php +++ b/question/type/essay/db/upgrade.php @@ -64,7 +64,7 @@ function xmldb_qtype_essay_upgrade($oldversion) { $sql"); foreach ($toupdate as $data) { - $progressbar->update($done, $count, "Updating essay feedback ($done/$count)."); + $progressbar->update($done, $count, "Updating essay feedback ({$done}/{$count})."); upgrade_set_timeout(60); if ($data->generalfeedbackformat == $data->feedbackformat) { $DB->set_field('question', 'generalfeedback', diff --git a/question/type/match/question.php b/question/type/match/question.php index b5edea247bd59..5ed2b5fd00200 100644 --- a/question/type/match/question.php +++ b/question/type/match/question.php @@ -202,7 +202,7 @@ public function prepare_simulated_post_data($simulatedresponse) { } else if ($choicetochoiceno[$choice]) { $choiceselectvalue = $choicenotochoiceselectvalue[$choicetochoiceno[$choice]]; } else { - throw new coding_exception("Unknown choice $choice in matching question - {$this->name}."); + throw new coding_exception("Unknown choice {$choice} in matching question - {$this->name}."); } $postdata[$this->field($shuffledstemno)] = $choiceselectvalue; } diff --git a/question/type/multianswer/edit_multianswer_form.php b/question/type/multianswer/edit_multianswer_form.php index 178733f26e34b..5f45ff5742f7a 100644 --- a/question/type/multianswer/edit_multianswer_form.php +++ b/question/type/multianswer/edit_multianswer_form.php @@ -296,7 +296,7 @@ public function set_data($question) { unset($wrapped->options->tolerance); } if ($subanswer->feedback) { - $parsableanswerdef .= "#$subanswer->feedback"; + $parsableanswerdef .= "#{$subanswer->feedback}"; } $separator = '~'; } diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php index 40a82b6a53204..00c412de730f3 100644 --- a/question/type/multianswer/questiontype.php +++ b/question/type/multianswer/questiontype.php @@ -396,23 +396,23 @@ function qtype_multianswer_extract_question($text) { $remainingalts = $answerregs[ANSWER_REGEX_ALTERNATIVES]; while (preg_match('/~?'.ANSWER_ALTERNATIVE_REGEX.'/s', $remainingalts, $altregs)) { if ('=' == $altregs[ANSWER_ALTERNATIVE_REGEX_FRACTION]) { - $wrapped->fraction["$answerindex"] = '1'; + $wrapped->fraction["{$answerindex}"] = '1'; } else if ($percentile = $altregs[ANSWER_ALTERNATIVE_REGEX_PERCENTILE_FRACTION]) { - $wrapped->fraction["$answerindex"] = .01 * $percentile; + $wrapped->fraction["{$answerindex}"] = .01 * $percentile; } else { - $wrapped->fraction["$answerindex"] = '0'; + $wrapped->fraction["{$answerindex}"] = '0'; } if (isset($altregs[ANSWER_ALTERNATIVE_REGEX_FEEDBACK])) { $feedback = html_entity_decode( $altregs[ANSWER_ALTERNATIVE_REGEX_FEEDBACK], ENT_QUOTES, 'UTF-8'); $feedback = str_replace('\}', '}', $feedback); - $wrapped->feedback["$answerindex"]['text'] = str_replace('\#', '#', $feedback); - $wrapped->feedback["$answerindex"]['format'] = FORMAT_HTML; - $wrapped->feedback["$answerindex"]['itemid'] = ''; + $wrapped->feedback["{$answerindex}"]['text'] = str_replace('\#', '#', $feedback); + $wrapped->feedback["{$answerindex}"]['format'] = FORMAT_HTML; + $wrapped->feedback["{$answerindex}"]['itemid'] = ''; } else { - $wrapped->feedback["$answerindex"]['text'] = ''; - $wrapped->feedback["$answerindex"]['format'] = FORMAT_HTML; - $wrapped->feedback["$answerindex"]['itemid'] = ''; + $wrapped->feedback["{$answerindex}"]['text'] = ''; + $wrapped->feedback["{$answerindex}"]['format'] = FORMAT_HTML; + $wrapped->feedback["{$answerindex}"]['itemid'] = ''; } if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL]) @@ -420,20 +420,20 @@ function qtype_multianswer_extract_question($text) { $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], $numregs)) { $wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER]; if (array_key_exists(NUMERICAL_ABS_ERROR_MARGIN, $numregs)) { - $wrapped->tolerance["$answerindex"] = + $wrapped->tolerance["{$answerindex}"] = $numregs[NUMERICAL_ABS_ERROR_MARGIN]; } else { - $wrapped->tolerance["$answerindex"] = 0; + $wrapped->tolerance["{$answerindex}"] = 0; } } else { // Tolerance can stay undefined for non numerical questions. // Undo quoting done by the HTML editor. $answer = html_entity_decode( $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER], ENT_QUOTES, 'UTF-8'); $answer = str_replace('\}', '}', $answer); - $wrapped->answer["$answerindex"] = str_replace('\#', '#', $answer); + $wrapped->answer["{$answerindex}"] = str_replace('\#', '#', $answer); if ($wrapped->qtype == 'multichoice') { - $wrapped->answer["$answerindex"] = array( - 'text' => $wrapped->answer["$answerindex"], + $wrapped->answer["{$answerindex}"] = array( + 'text' => $wrapped->answer["{$answerindex}"], 'format' => FORMAT_HTML, 'itemid' => ''); } diff --git a/question/type/numerical/edit_numerical_form.php b/question/type/numerical/edit_numerical_form.php index e99cdd6551e55..1d895507d3155 100644 --- a/question/type/numerical/edit_numerical_form.php +++ b/question/type/numerical/edit_numerical_form.php @@ -210,7 +210,7 @@ protected function data_preprocessing_answers($question, $withanswerfiles = fals $key = 0; foreach ($question->options->answers as $answer) { // See comment in the parent method about this hack. - unset($this->_form->_defaultValues["tolerance[$key]"]); + unset($this->_form->_defaultValues["tolerance[{$key}]"]); $question->tolerance[$key] = $answer->tolerance; $key++; diff --git a/question/type/numerical/questiontype.php b/question/type/numerical/questiontype.php index 2d290aacb57fc..f1b2a868b40ba 100644 --- a/question/type/numerical/questiontype.php +++ b/question/type/numerical/questiontype.php @@ -433,7 +433,7 @@ public function get_possible_responses($questiondata) { $ans = new qtype_numerical_answer($answer->id, $answer->answer, $answer->fraction, $answer->feedback, $answer->feedbackformat, $answer->tolerance); list($min, $max) = $ans->get_tolerance_interval(); - $responseclass .= " ($min..$max)"; + $responseclass .= " ({$min}..{$max})"; } $responses[$aid] = new question_possible_response($responseclass, @@ -569,12 +569,12 @@ protected function build_regex() { $decimalsre = $decsep . '(\d*)'; $exponentre = '(?:e|E|(?:x|\*|×)10(?:\^|\*\*))([+-]?\d+)'; - $numberbit = "$beforepointre(?:$decimalsre)?(?:$exponentre)?"; + $numberbit = "{$beforepointre}(?:{$decimalsre})?(?:{$exponentre})?"; if ($this->unitsbefore) { - $this->regex = "/$numberbit$/"; + $this->regex = "/{$numberbit}$/"; } else { - $this->regex = "/^$numberbit/"; + $this->regex = "/^{$numberbit}/"; } return $this->regex; } @@ -645,9 +645,9 @@ public function apply_units($response, $separateunit = null) { $regex = '[+-]?(?:\d+(?:\\.\d*)?|\\.\d+)(?:e[-+]?\d+)?'; if ($this->unitsbefore) { - $regex = "/$regex$/"; + $regex = "/{$regex}$/"; } else { - $regex = "/^$regex/"; + $regex = "/^{$regex}/"; } if (!preg_match($regex, $response, $matches)) { return array(null, null, null); diff --git a/question/type/questiontypebase.php b/question/type/questiontypebase.php index c0cfbac8255ad..256ebe561ea50 100644 --- a/question/type/questiontypebase.php +++ b/question/type/questiontypebase.php @@ -417,7 +417,7 @@ public function save_question($question, $form) { } if (!empty($result->notice)) { - notice($result->notice, "question.php?id=$question->id"); + notice($result->notice, "question.php?id={$question->id}"); } if (!empty($result->noticeyesno)) { @@ -1181,7 +1181,7 @@ public function export_to_xml($question, qformat_xml $format, $extra=null) { $expout=''; foreach ($extraquestionfields as $field) { $exportedvalue = $format->xml_escape($question->options->$field); - $expout .= " <$field>{$exportedvalue}$field>\n"; + $expout .= " <{$field}>{$exportedvalue}{$field}>\n"; } $extraanswersfields = $this->extra_answer_fields(); diff --git a/question/type/random/questiontype.php b/question/type/random/questiontype.php index 97ea6e2ada695..3d1f0b7539ac6 100644 --- a/question/type/random/questiontype.php +++ b/question/type/random/questiontype.php @@ -86,7 +86,7 @@ public function is_question_manual_graded($question, $otherquestionsinuse) { list($qcsql, $qcparams) = $DB->get_in_or_equal($categorylist); // TODO use in_or_equal for $otherquestionsinuse and $this->manualqtypes. return $DB->record_exists_select('question', - "category $qcsql + "category {$qcsql} AND parent = 0 AND hidden = 0 AND id NOT IN ($otherquestionsinuse) diff --git a/question/type/randomsamatch/questiontype.php b/question/type/randomsamatch/questiontype.php index c05c26300bc4c..5c11f9c342ae3 100644 --- a/question/type/randomsamatch/questiontype.php +++ b/question/type/randomsamatch/questiontype.php @@ -227,7 +227,7 @@ public function export_to_xml($question, qformat_xml $format, $extra=null) { $extraquestionfields = $this->extra_question_fields(); array_shift($extraquestionfields); foreach ($extraquestionfields as $extra) { - $expout .= " <$extra>" . $question->options->$extra . "$extra>\n"; + $expout .= " <{$extra}>" . $question->options->$extra . "{$extra}>\n"; } return $expout; } diff --git a/question/type/shortanswer/edit_shortanswer_form.php b/question/type/shortanswer/edit_shortanswer_form.php index c707749ca7f9b..50971ec7227db 100644 --- a/question/type/shortanswer/edit_shortanswer_form.php +++ b/question/type/shortanswer/edit_shortanswer_form.php @@ -80,7 +80,7 @@ public function validation($data, $files) { } } else if ($data['fraction'][$key] != 0 || !html_is_blank($data['feedback'][$key]['text'])) { - $errors["answeroptions[$key]"] = get_string('answermustbegiven', 'qtype_shortanswer'); + $errors["answeroptions[{$key}]"] = get_string('answermustbegiven', 'qtype_shortanswer'); $answercount++; } } |