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 "
$showall
"; + echo "
{$showall}
"; } echo ''; @@ -743,13 +743,13 @@ protected function display_question_list($contexts, $pageurl, $categoryandcontex if ($canmoveall && count($addcontexts)) { echo '\n"; - question_category_select_menu($addcontexts, false, 0, "$category->id,$category->contextid"); + question_category_select_menu($addcontexts, false, 0, "{$category->id},{$category->contextid}"); } if (function_exists('module_specific_controls') && $canuseall) { $modulespecific = module_specific_controls($totalnumber, $recurse, $category, $this->cm->id, $cmoptions); if (!empty($modulespecific)) { - echo "
$modulespecific"; + echo "
{$modulespecific}"; } } } @@ -835,13 +835,13 @@ public function process_actions() { SELECT q.*, c.contextid FROM {question} q JOIN {question_categories} c ON c.id = q.category - WHERE q.id $usql", $params); + WHERE q.id {$usql}", $params); foreach ($questions as $question) { question_require_capability_on($question, 'move'); } question_move_questions_to_category($questionids, $tocategory->id); redirect($this->baseurl->out(false, - array('category' => "$tocategoryid,$contextid"))); + array('category' => "{$tocategoryid},{$contextid}"))); } } diff --git a/question/editlib.php b/question/editlib.php index 27397000f2738..cb7348e9ae5b3 100644 --- a/question/editlib.php +++ b/question/editlib.php @@ -75,7 +75,7 @@ function get_questions_category( $category, $noparent=false, $recurse=true, $exp // Get the list of questions for the category list($usql, $params) = $DB->get_in_or_equal($categorylist); - $questions = $DB->get_records_select('question', "category $usql $npsql", $params, 'qtype, name'); + $questions = $DB->get_records_select('question', "category {$usql} {$npsql}", $params, 'qtype, name'); // Iterate through questions, getting stuff we need $qresults = array(); @@ -346,7 +346,7 @@ function question_edit_setup($edittab, $baseurl, $requirecmid = false, $requirec $contextlistarr = array(); foreach ($contexts->having_one_edit_tab_cap($edittab) as $context){ - $contextlistarr[] = "'$context->id'"; + $contextlistarr[] = "'{$context->id}'"; } $contextlist = join($contextlistarr, ' ,'); if (!empty($pagevars['cat'])){ @@ -357,7 +357,7 @@ function question_edit_setup($edittab, $baseurl, $requirecmid = false, $requirec } } else { $category = $defaultcategory; - $pagevars['cat'] = "$category->id,$category->contextid"; + $pagevars['cat'] = "{$category->id},{$category->contextid}"; } // Display options. diff --git a/question/engine/bank.php b/question/engine/bank.php index 5950af6734d9d..11e3ddca86232 100644 --- a/question/engine/bank.php +++ b/question/engine/bank.php @@ -100,7 +100,7 @@ public static function get_qtype($qtypename, $mustexist = true) { include_once($file); $class = 'qtype_' . $qtypename; if (!class_exists($class)) { - throw new coding_exception("Class $class must be defined in $file"); + throw new coding_exception("Class {$class} must be defined in {$file}."); } self::$questiontypes[$qtypename] = new $class(); return self::$questiontypes[$qtypename]; @@ -381,8 +381,8 @@ protected static function ensure_fraction_options_initialised() { // The the positive grades in descending order. foreach ($rawfractions as $fraction) { $percentage = format_float(100 * $fraction, 5, true, true) . '%'; - self::$fractionoptions["$fraction"] = $percentage; - self::$fractionoptionsfull["$fraction"] = $percentage; + self::$fractionoptions["{$fraction}"] = $percentage; + self::$fractionoptionsfull["{$fraction}"] = $percentage; } // The the negative grades in descending order. @@ -499,10 +499,10 @@ public function get_questions_from_categories($categoryids, $extraconditions, } return $DB->get_records_select_menu('question', - "category $qcsql + "category {$qcsql} AND parent = 0 AND hidden = 0 - $extraconditions", $qcparams + $extraparams, '', 'id,id AS id2'); + {$extraconditions}", $qcparams + $extraparams, '', 'id,id AS id2'); } /* See cache_data_source::load_for_cache. */ diff --git a/question/engine/datalib.php b/question/engine/datalib.php index 7b0685c2157cc..daaa0f61a7563 100644 --- a/question/engine/datalib.php +++ b/question/engine/datalib.php @@ -651,7 +651,7 @@ public function load_average_marks(qubaid_condition $qubaids, $slots = null) { if (!empty($slots)) { list($slottest, $slotsparams) = $this->db->get_in_or_equal( $slots, SQL_PARAMS_NAMED, 'slot'); - $slotwhere = " AND qa.slot $slottest"; + $slotwhere = " AND qa.slot {$slottest}"; } else { $slotwhere = ''; $slotsparams = array(); @@ -879,9 +879,9 @@ public function delete_steps($stepids, $context) { $this->delete_response_files($context->id, $test, $params); $this->db->delete_records_select('question_attempt_step_data', - "attemptstepid $test", $params); + "attemptstepid {$test}", $params); $this->db->delete_records_select('question_attempt_steps', - "id $test", $params); + "id {$test}", $params); } /** @@ -942,7 +942,7 @@ public function update_question_attempt_flag($qubaid, $questionid, $qaid, $slot, protected function full_states_to_summary_state_sql() { $sql = ''; foreach (question_state::get_all() as $state) { - $sql .= "WHEN '$state' THEN '{$state->get_summary_state()}'\n"; + $sql .= "WHEN '{$state}' THEN '{$state->get_summary_state()}'\n"; } return $sql; } @@ -1043,7 +1043,7 @@ public function question_attempt_latest_state_view($alias, qubaid_condition $qub JOIN {question_attempt_steps} {$alias}qas ON {$alias}qas.questionattemptid = {$alias}qa.id AND {$alias}qas.sequencenumber = {$this->latest_step_for_qa_subquery($alias . 'qa.id')} WHERE {$qubaids->where()} - ) $alias", $qubaids->from_where_params()); + ) {$alias}", $qubaids->from_where_params()); } protected function latest_step_for_qa_subquery($questionattemptid = 'qa.id') { @@ -1658,7 +1658,7 @@ public function __construct($from, $usageidcolumn, $where = '', $params = array( } public function from_question_attempts($alias) { - return "$this->from + return "{$this->from} JOIN {question_attempts} {$alias} ON " . "{$alias}.questionusageid = $this->usageidcolumn"; } @@ -1672,7 +1672,7 @@ public function from_where_params() { } public function usage_id_in() { - return "IN (SELECT $this->usageidcolumn FROM $this->from WHERE $this->where)"; + return "IN (SELECT {$this->usageidcolumn} FROM {$this->from} WHERE {$this->where})"; } public function usage_id_in_params() { diff --git a/question/engine/lib.php b/question/engine/lib.php index c96659becd1d6..ef0642633623e 100644 --- a/question/engine/lib.php +++ b/question/engine/lib.php @@ -656,7 +656,7 @@ public static function get_postdata(question_attempt $qa) { $qid = $qa->get_question()->id; $slot = $qa->get_slot(); $checksum = self::get_toggle_checksum($qubaid, $qid, $qaid, $slot); - return "qaid=$qaid&qubaid=$qubaid&qid=$qid&slot=$slot&checksum=$checksum&sesskey=" . + return "qaid={$qaid}&qubaid={$qubaid}&qid={$qid}&slot={$slot}&checksum={$checksum}&sesskey=" . sesskey() . '&newstate='; } @@ -735,7 +735,7 @@ public function __construct($qubaid, $slot, $postdata) { $postdata = data_submitted(); } parent::__construct('submissionoutofsequence', 'question', '', null, - "QUBAid: $qubaid, slot: $slot, post data: " . print_r($postdata, true)); + "QUBAid: {$qubaid}, slot: {$slot}, post data: " . print_r($postdata, true)); } } diff --git a/question/engine/questionattempt.php b/question/engine/questionattempt.php index bce04651e8d4a..3d1c55b96d578 100644 --- a/question/engine/questionattempt.php +++ b/question/engine/questionattempt.php @@ -1351,7 +1351,7 @@ public static function load_from_records($records, $questionattemptid, while ($record->questionattemptid != $questionattemptid) { $record = $records->next(); if (!$records->valid()) { - throw new coding_exception("Question attempt $questionattemptid not found in the database."); + throw new coding_exception("Question attempt {$questionattemptid} not found in the database."); } $record = $records->current(); } diff --git a/question/engine/questionusage.php b/question/engine/questionusage.php index 7a4d5ed4091e4..20d0a6a8f2f5a 100644 --- a/question/engine/questionusage.php +++ b/question/engine/questionusage.php @@ -837,7 +837,7 @@ public static function load_from_records($records, $qubaid) { while ($record->qubaid != $qubaid) { $records->next(); if (!$records->valid()) { - throw new coding_exception("Question usage $qubaid not found in the database."); + throw new coding_exception("Question usage {$qubaid} not found in the database."); } $record = $records->current(); } diff --git a/question/engine/tests/helpers.php b/question/engine/tests/helpers.php index fc97d585dbce6..551633823e719 100644 --- a/question/engine/tests/helpers.php +++ b/question/engine/tests/helpers.php @@ -545,10 +545,10 @@ public function assert($expectation, $compare, $notused = '') { $compare = (array)$compare; foreach ($expect as $k=>$v) { if (!array_key_exists($k, $compare)) { - $this->fail("Property $k does not exist"); + $this->fail("Property {$k} does not exist"); } if ($v != $compare[$k]) { - $this->fail("Property $k is different"); + $this->fail("Property {$k} is different"); } } $this->assertTrue(true); diff --git a/question/export.php b/question/export.php index 8f2396eb011fb..892cf75b44fb8 100644 --- a/question/export.php +++ b/question/export.php @@ -50,7 +50,7 @@ if ($from_form = $export_form->get_data()) { $thiscontext = $contexts->lowest(); - if (!is_readable("format/$from_form->format/format.php")) { + if (!is_readable("format/{$from_form->format}/format.php")) { print_error('unknowformat', '', '', $from_form->format); } $withcategories = 'nocategories'; diff --git a/question/export_form.php b/question/export_form.php index 547abf20e0725..006e334472caa 100644 --- a/question/export_form.php +++ b/question/export_form.php @@ -51,10 +51,10 @@ protected function definition() { foreach ($fileformatnames as $shortname => $fileformatname) { $currentgrp1 = array(); $currentgrp1[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname); - $mform->addGroup($currentgrp1, "formathelp[$i]", '', array('
'), false); + $mform->addGroup($currentgrp1, "formathelp[{$i}]", '', array('
'), false); if (get_string_manager()->string_exists('pluginname_help', 'qformat_' . $shortname)) { - $mform->addHelpButton("formathelp[$i]", 'pluginname', 'qformat_' . $shortname); + $mform->addHelpButton("formathelp[{$i}]", 'pluginname', 'qformat_' . $shortname); } $i++ ; diff --git a/question/format.php b/question/format.php index 51b46728e4afd..e284d8cdaaa23 100644 --- a/question/format.php +++ b/question/format.php @@ -222,12 +222,12 @@ protected function error($message, $text='', $questionname='') { $importerrorquestion = get_string('importerrorquestion', 'question'); echo "
\n"; - echo "$importerrorquestion $questionname"; + echo "{$importerrorquestion} {$questionname}"; if (!empty($text)) { $text = s($text); - echo "
$text
\n"; + echo "
{$text}
\n"; } - echo "$message\n"; + echo "{$message}\n"; echo "
"; $this->importerrors++; @@ -247,7 +247,7 @@ public function try_importing_using_qtypes($data, $question = null, $extra = nul // work out what format we are using $formatname = substr(get_class($this), strlen('qformat_')); - $methodname = "import_from_$formatname"; + $methodname = "import_from_{$formatname}"; //first try importing using a hint from format if (!empty($qtypehint)) { @@ -377,7 +377,7 @@ public function importprocess($category) { $count++; - 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)).'

'; unset($questions); // No questions imported. @@ -867,7 +867,7 @@ public function readquestions ($lines) { if (count($warnings) > 0) { echo '

'.get_string('warningsdetected', 'qformat_webct', count($warnings)).'

'; } diff --git a/question/format/xhtml/format.php b/question/format/xhtml/format.php index 0c625881990b2..bb54d80c04cef 100644 --- a/question/format/xhtml/format.php +++ b/question/format/xhtml/format.php @@ -59,11 +59,11 @@ protected function writequestion($question) { $id = $question->id; // Add comment and div tags. - $expout .= "\n"; + $expout .= "\n"; $expout .= "
\n"; // Add header. - $expout .= "

$question->name

\n"; + $expout .= "

{$question->name}

\n"; // Format and add the question text. $text = question_rewrite_question_preview_urls($question->questiontext, $question->id, @@ -78,8 +78,8 @@ protected function writequestion($question) { $sttrue = get_string('true', 'qtype_truefalse'); $stfalse = get_string('false', 'qtype_truefalse'); $expout .= "\n"; break; case 'multichoice': @@ -87,11 +87,11 @@ protected function writequestion($question) { foreach ($question->options->answers as $answer) { $answertext = $this->repchar( $answer->answer ); if ($question->options->single) { - $expout .= "
  • $answertext
  • \n"; + $expout .= "
  • {$answertext}
  • \n"; } else { - $expout .= "
  • $answertext
  • \n"; + $expout .= "
  • {$answertext}
  • \n"; } } $expout .= "\n"; @@ -100,7 +100,7 @@ protected function writequestion($question) { $expout .= html_writer::start_tag('ul', array('class' => 'shortanswer')); $expout .= html_writer::start_tag('li'); $expout .= html_writer::label(get_string('answer'), 'quest_'.$id, false, array('class' => 'accesshide')); - $expout .= html_writer::empty_tag('input', array('id' => "quest_$id", 'name' => "quest_$id", 'type' => 'text')); + $expout .= html_writer::empty_tag('input', array('id' => "quest_{$id}", 'name' => "quest_{$id}", 'type' => 'text')); $expout .= html_writer::end_tag('li'); $expout .= html_writer::end_tag('ul'); break; @@ -108,7 +108,7 @@ protected function writequestion($question) { $expout .= html_writer::start_tag('ul', array('class' => 'numerical')); $expout .= html_writer::start_tag('li'); $expout .= html_writer::label(get_string('answer'), 'quest_'.$id, false, array('class' => 'accesshide')); - $expout .= html_writer::empty_tag('input', array('id' => "quest_$id", 'name' => "quest_$id", 'type' => 'text')); + $expout .= html_writer::empty_tag('input', array('id' => "quest_{$id}", 'name' => "quest_{$id}", 'type' => 'text')); $expout .= html_writer::end_tag('li'); $expout .= html_writer::end_tag('ul'); break; @@ -149,7 +149,7 @@ protected function writequestion($question) { break; case 'multianswer': default: - $expout .= "\n"; + $expout .= "\n"; } // Close off div. $expout .= "
    \n\n\n"; @@ -163,7 +163,7 @@ protected function presave_process($content) { global $CFG; // Get css bit. - $csslines = file( "$CFG->dirroot/question/format/xhtml/xhtml.css" ); + $csslines = file( "{$CFG->dirroot}/question/format/xhtml/xhtml.css" ); $css = implode( ' ', $csslines ); $xp = "xml_escape($raw); if ($short) { - $xml = "$indent$raw\n"; + $xml = "{$indent}{$raw}\n"; } else { - $xml = "$indent\n$raw\n$indent\n"; + $xml = "{$indent}\n{$raw}\n{$indent}\n"; } return $xml; @@ -1137,7 +1137,7 @@ public function writequestion($question) { $expout = ''; // Add a comment linking this to the original question id. - $expout .= "\n"; + $expout .= "\n"; // Check question type. $questiontype = $this->get_qtype($question->qtype); @@ -1147,7 +1147,7 @@ public function writequestion($question) { $categorypath = $this->writetext($question->category); $expout .= " \n"; $expout .= " \n"; - $expout .= " $categorypath\n"; + $expout .= " {$categorypath}\n"; $expout .= " \n"; $expout .= " \n"; return $expout; @@ -1155,7 +1155,7 @@ public function writequestion($question) { // Now we know we are are handing a real question. // Output the generic information. - $expout .= " \n"; + $expout .= " \n"; $expout .= " \n"; $expout .= $this->writetext($question->name, 3); $expout .= " \n"; @@ -1209,7 +1209,7 @@ public function writequestion($question) { case 'numerical': foreach ($question->options->answers as $answer) { $expout .= $this->write_answer($answer, - " $answer->tolerance\n"); + " {$answer->tolerance}\n"); } $units = $question->options->units; @@ -1333,7 +1333,7 @@ public function writequestion($question) { foreach ($question->options->answers as $answer) { $percent = 100 * $answer->fraction; - $expout .= "\n"; + $expout .= "\n"; // The "" tags are an added feature, old files won't have them. $expout .= " {$answer->answer}\n"; $expout .= " {$answer->tolerance}\n"; @@ -1412,7 +1412,7 @@ public function writequestion($question) { "\n"; $expout .= " " . $this->writetext($def->decimals) . "\n"; - $expout .= " $def->itemcount\n"; + $expout .= " {$def->itemcount}\n"; if ($def->itemcount > 0) { $expout .= " \n"; foreach ($def->items as $item) { @@ -1479,7 +1479,7 @@ public function write_answers($answers) { public function write_answer($answer, $extra = '') { $percent = $answer->fraction * 100; $output = ''; - $output .= " format($answer->answerformat)}>\n"; + $output .= " format($answer->answerformat)}>\n"; $output .= $this->writetext($answer->answer, 3); $output .= $this->write_files($answer->answerfiles); $output .= " format($answer->feedbackformat)}>\n"; diff --git a/question/import_form.php b/question/import_form.php index 7112db538e4c1..323aea7f9da4a 100644 --- a/question/import_form.php +++ b/question/import_form.php @@ -53,10 +53,10 @@ protected function definition() { foreach ($fileformatnames as $shortname => $fileformatname) { $currentgrp1 = array(); $currentgrp1[] = $mform->createElement('radio', 'format', '', $fileformatname, $shortname); - $mform->addGroup($currentgrp1, "formathelp[$i]", '', array('
    '), false); + $mform->addGroup($currentgrp1, "formathelp[{$i}]", '', array('
    '), false); if (get_string_manager()->string_exists('pluginname_help', 'qformat_' . $shortname)) { - $mform->addHelpButton("formathelp[$i]", 'pluginname', 'qformat_' . $shortname); + $mform->addHelpButton("formathelp[{$i}]", 'pluginname', 'qformat_' . $shortname); } $i++ ; diff --git a/question/previewlib.php b/question/previewlib.php index c4aa54f6dd978..00c8d2394a5e8 100644 --- a/question/previewlib.php +++ b/question/previewlib.php @@ -259,7 +259,7 @@ function question_preview_question_pluginfile($course, $context, $component, $fs = get_file_storage(); $relativepath = implode('/', $args); - $fullpath = "/$context->id/$component/$filearea/$relativepath"; + $fullpath = "/{$context->id}/{$component}/{$filearea}/{$relativepath}"; if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) { send_file_not_found(); } diff --git a/question/question.php b/question/question.php index 45cf3e6ea1682..a11f971e2d8c9 100644 --- a/question/question.php +++ b/question/question.php @@ -188,7 +188,7 @@ $mform = $qtypeobj->create_editing_form('question.php', $question, $category, $contexts, $formeditable); } $toform = fullclone($question); // send the question object and a few more parameters to the form -$toform->category = "$category->id,$category->contextid"; +$toform->category = "{$category->id},{$category->contextid}"; $toform->scrollpos = $scrollpos; if ($formeditable && $id){ $toform->categorymoveto = $toform->category; @@ -317,7 +317,7 @@ $streditingmodule = get_string('editinga', 'moodle', $strmodule); $PAGE->navbar->add(get_string('modulenameplural', $cm->modname), new moodle_url('/mod/'.$cm->modname.'/index.php', array('id'=>$cm->course))); $PAGE->navbar->add(format_string($module->name), new moodle_url('/mod/'.$cm->modname.'/view.php', array('id'=>$cm->id))); - if (stripos($returnurl, "$CFG->wwwroot/mod/{$cm->modname}/view.php")!== 0){ + if (stripos($returnurl, "{$CFG->wwwroot}/mod/{$cm->modname}/view.php")!== 0){ //don't need this link if returnurl returns to view.php $PAGE->navbar->add($streditingmodule, $returnurl); } diff --git a/question/tests/behat/behat_question.php b/question/tests/behat/behat_question.php index 00e0e3884483e..0214f51ad422b 100644 --- a/question/tests/behat/behat_question.php +++ b/question/tests/behat/behat_question.php @@ -75,12 +75,12 @@ public function the_state_of_question_is_shown_as($questiondescription, $state) // Split in two checkings to give more feedback in case of exception. $exception = new ElementNotFoundException($this->getSession(), 'Question "' . $questiondescription . '" '); - $questionxpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' qtext ')][contains(., $questiondescriptionliteral)]"; + $questionxpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' qtext ')][contains(., {$questiondescriptionliteral})]"; $this->find('xpath', $questionxpath, $exception); $exception = new ExpectationException('Question "' . $questiondescription . '" state is not "' . $state . '"', $this->getSession()); $xpath = $questionxpath . "/ancestor::div[contains(concat(' ', normalize-space(@class), ' '), ' que ')]" . - "/descendant::div[@class='state'][contains(., $stateliteral)]"; + "/descendant::div[@class='state'][contains(., {$stateliteral})]"; $this->find('xpath', $xpath, $exception); } } diff --git a/question/type/calculated/datasetdefinitions_form.php b/question/type/calculated/datasetdefinitions_form.php index a5fdac391a35e..67334c397c69a 100644 --- a/question/type/calculated/datasetdefinitions_form.php +++ b/question/type/calculated/datasetdefinitions_form.php @@ -104,14 +104,14 @@ protected function definition() { $this->qtypeobj->dataset_options($this->question, $datasetname); unset($options['0']); // Mandatory... $label = get_string('wildcard', 'qtype_calculated', $datasetname); - $mform->addElement('select', "dataset[$key]", $label, $options); + $mform->addElement('select', "dataset[{$key}]", $label, $options); if (isset($datadefscat[$datasetname])) { $mform->addElement('static', "there is a category", get_string('sharedwildcard', 'qtype_calculated', $datasetname), get_string('dataitemdefined', 'qtype_calculated', $datadefscat[$datasetname])); } - $mform->setDefault("dataset[$key]", $selected); + $mform->setDefault("dataset[{$key}]", $selected); $datasetmenus[$datasetname] = ''; $key++; } @@ -123,7 +123,7 @@ protected function definition() { list($options, $selected) = $this->qtypeobj->dataset_options( $this->question, $datasetname, false); $label = get_string('wildcard', 'qtype_calculated', $datasetname); - $mform->addElement('select', "dataset[$key]", $label, $options); + $mform->addElement('select', "dataset[{$key}]", $label, $options); if (isset($datadefscat[$datasetname])) { $mform->addElement('static', "there is a category", get_string('sharedwildcard', 'qtype_calculated', $datasetname), @@ -131,7 +131,7 @@ protected function definition() { $datadefscat[$datasetname])); } - $mform->setDefault("dataset[$key]", $selected); + $mform->setDefault("dataset[{$key}]", $selected); $datasetmenus[$datasetname] = ''; $key++; } diff --git a/question/type/calculated/datasetitems_form.php b/question/type/calculated/datasetitems_form.php index 4fba8f3822b75..348289420e632 100644 --- a/question/type/calculated/datasetitems_form.php +++ b/question/type/calculated/datasetitems_form.php @@ -146,16 +146,16 @@ protected function definition() { } else { $name = get_string('wildcard', 'qtype_calculated', $datasetdef->name); } - $mform->addElement('text', "number[$j]", $name); - $mform->setType("number[$j]", PARAM_RAW); // This parameter will be validated in validation(). + $mform->addElement('text', "number[{$j}]", $name); + $mform->setType("number[{$j}]", PARAM_RAW); // This parameter will be validated in validation(). $this->qtypeobj->custom_generator_tools_part($mform, $idx, $j); $idx++; - $mform->addElement('hidden', "definition[$j]"); - $mform->setType("definition[$j]", PARAM_RAW); - $mform->addElement('hidden', "itemid[$j]"); - $mform->setType("itemid[$j]", PARAM_RAW); - $mform->addElement('static', "divider[$j]", '', '
    '); - $mform->setType("divider[$j]", PARAM_RAW); + $mform->addElement('hidden', "definition[{$j}]"); + $mform->setType("definition[{$j}]", PARAM_RAW); + $mform->addElement('hidden', "itemid[{$j}]"); + $mform->setType("itemid[{$j}]", PARAM_RAW); + $mform->addElement('static', "divider[{$j}]", '', '
    '); + $mform->setType("divider[{$j}]", PARAM_RAW); $j++; } @@ -218,14 +218,14 @@ protected function definition() { $addremoveoptions = array(); $addremoveoptions['1']='1'; for ($i=10; $i<=100; $i+=10) { - $addremoveoptions["$i"]="$i"; + $addremoveoptions["{$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->addElement('header', 'addhdr', get_string('add', 'moodle')); $mform->closeHeaderBefore('addhdr'); @@ -287,35 +287,35 @@ protected function definition() { foreach ($this->datasetdefs as $defkey => $datasetdef) { if ($k > 0) { if ($datasetdef->category == 0 ) { - $mform->addElement('text', "number[$j]", + $mform->addElement('text', "number[{$j}]", get_string('wildcard', 'qtype_calculated', $datasetdef->name)); } else { - $mform->addElement('text', "number[$j]", get_string( + $mform->addElement('text', "number[{$j}]", get_string( 'sharedwildcard', 'qtype_calculated', $datasetdef->name)); } } else { - $mform->addElement('hidden', "number[$j]" , ''); + $mform->addElement('hidden', "number[{$j}]" , ''); } - $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->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', "definition[$j]"); - $mform->setType("definition[$j]", PARAM_NOTAGS); + $mform->addElement('hidden', "definition[{$j}]"); + $mform->setType("definition[{$j}]", PARAM_NOTAGS); $data[$datasetdef->name] =$datasetdef->items[$i]->value; $j--; } if ('' != $strquestionlabel && ($k > 0 )) { // ... $this->outsidelimit || !empty($this->numbererrors ). - $repeated[] = $mform->addElement('static', "answercomment[$i]", $strquestionlabel); + $repeated[] = $mform->addElement('static', "answercomment[{$i}]", $strquestionlabel); // Decode equations in question text. $qtext = $this->qtypeobj->substitute_variables( $this->question->questiontext, $data); $textequations = $this->qtypeobj->find_math_equations($qtext); if ($textequations != '' && count($textequations) > 0 ) { - $mform->addElement('static', "divider1[$j]", '', + $mform->addElement('static', "divider1[{$j}]", '', 'Formulas {=..} in question text'); foreach ($textequations as $key => $equation) { if ($formulaerrors = qtype_calculated_find_formula_errors($equation)) { @@ -324,7 +324,7 @@ protected function definition() { eval('$str = '.$equation.';'); } $equation = shorten_text($equation, 17, true); - $mform->addElement('static', "textequation", "{=$equation}", "=".$str); + $mform->addElement('static', "textequation", "{={$equation}}", "=".$str); } } @@ -408,9 +408,9 @@ public function set_data($question) { $data = array(); foreach ($this->datasetdefs as $defid => $datasetdef) { if (isset($datasetdef->items[$itemnumber])) { - $formdata["number[$j]"] = $datasetdef->items[$itemnumber]->value; - $formdata["definition[$j]"] = $defid; - $formdata["itemid[$j]"] = $datasetdef->items[$itemnumber]->id; + $formdata["number[{$j}]"] = $datasetdef->items[$itemnumber]->value; + $formdata["definition[{$j}]"] = $defid; + $formdata["itemid[{$j}]"] = $datasetdef->items[$itemnumber]->id; $data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value; } $j--; @@ -438,15 +438,15 @@ public function set_data($question) { foreach ($this->datasetdefs as $defid => $datasetdef) { if (!optional_param('updatedatasets', false, PARAM_BOOL) && !optional_param('updateanswers', false, PARAM_BOOL)) { - $formdata["number[$j]"] = $this->qtypeobj->generate_dataset_item( + $formdata["number[{$j}]"] = $this->qtypeobj->generate_dataset_item( $datasetdef->options); } else { - $formdata["number[$j]"] = $this->_form->getElementValue("number[$j]"); + $formdata["number[{$j}]"] = $this->_form->getElementValue("number[{$j}]"); } - $formdata["definition[$j]"] = $defid; - $formdata["itemid[$j]"] = isset($datasetdef->items[$itemnumber]) ? + $formdata["definition[{$j}]"] = $defid; + $formdata["itemid[{$j}]"] = isset($datasetdef->items[$itemnumber]) ? $datasetdef->items[$itemnumber]->id : 0; - $data[$datasetdef->name] = $formdata["number[$j]"]; + $data[$datasetdef->name] = $formdata["number[{$j}]"]; $j++; } } @@ -459,9 +459,9 @@ public function set_data($question) { $itemnumber = $this->noofitems + 1; foreach ($this->datasetdefs as $defid => $datasetdef) { if (isset($datasetdef->items[$itemnumber])) { - $formdata["number[$j]"] = $datasetdef->items[$itemnumber]->value; - $formdata["definition[$j]"] = $defid; - $formdata["itemid[$j]"] = $datasetdef->items[$itemnumber]->id; + $formdata["number[{$j}]"] = $datasetdef->items[$itemnumber]->value; + $formdata["definition[{$j}]"] = $defid; + $formdata["itemid[{$j}]"] = $datasetdef->items[$itemnumber]->id; $data[$datasetdef->name] = $datasetdef->items[$itemnumber]->value; } $j++; diff --git a/question/type/calculated/edit_calculated_form.php b/question/type/calculated/edit_calculated_form.php index 853030d383c7d..3113c39b8bbf4 100644 --- a/question/type/calculated/edit_calculated_form.php +++ b/question/type/calculated/edit_calculated_form.php @@ -199,9 +199,9 @@ 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["tolerancetype[$key]"]); - unset($this->_form->_defaultValues["correctanswerlength[$key]"]); - unset($this->_form->_defaultValues["correctanswerformat[$key]"]); + unset($this->_form->_defaultValues["tolerancetype[{$key}]"]); + unset($this->_form->_defaultValues["correctanswerlength[{$key}]"]); + unset($this->_form->_defaultValues["correctanswerformat[{$key}]"]); $question->tolerancetype[$key] = $answer->tolerancetype; $question->correctanswerlength[$key] = $answer->correctanswerlength; diff --git a/question/type/calculated/question.php b/question/type/calculated/question.php index 71b25a6790bbb..bef1253c582c7 100644 --- a/question/type/calculated/question.php +++ b/question/type/calculated/question.php @@ -384,8 +384,8 @@ public function format_float($x, $length = null, $format = null) { } } else { // Stick to plain numeric format. - $answer *= "1e$p10"; - if (0.1 <= $answer / "1e$length") { + $answer *= "1e{$p10}"; + if (0.1 <= $answer / "1e{$length}") { $x = $sign.$answer; } else { // Could be an idea to add some zeros here. @@ -492,10 +492,10 @@ public function get_formula_errors($formula) { $formula = strtolower(str_replace(' ', '', $formula)); $safeoperatorchar = '-+/*%>:^\~number_of_items = $n; } } - $datasetdefs["1-$r->category-$r->name"] = $def; + $datasetdefs["1-{$r->category}-{$r->name}"] = $def; } } } @@ -404,11 +404,11 @@ public function print_next_wizard_page($question, $form, $course) { // See where we're coming from. switch($form->wizardpage) { case 'question': - require("$CFG->dirroot/question/type/calculated/datasetdefinitions.php"); + require("{$CFG->dirroot}/question/type/calculated/datasetdefinitions.php"); break; case 'datasetdefinitions': case 'datasetitems': - require("$CFG->dirroot/question/type/calculated/datasetitems.php"); + require("{$CFG->dirroot}/question/type/calculated/datasetitems.php"); break; default: print_error('invalidwizardpage', 'question'); @@ -432,15 +432,15 @@ public function &next_wizard_form($submiturl, $question, $wizardnow) { // See where we're coming from. switch($wizardnow) { case 'datasetdefinitions': - require("$CFG->dirroot/question/type/calculated/datasetdefinitions_form.php"); + require("{$CFG->dirroot}/question/type/calculated/datasetdefinitions_form.php"); $mform = new question_dataset_dependent_definitions_form( - "$submiturl?wizardnow=datasetdefinitions", $question); + "{$submiturl}?wizardnow=datasetdefinitions", $question); break; case 'datasetitems': - require("$CFG->dirroot/question/type/calculated/datasetitems_form.php"); + require("{$CFG->dirroot}/question/type/calculated/datasetitems_form.php"); $regenerate = optional_param('forceregeneration', false, PARAM_BOOL); $mform = new question_dataset_dependent_items_form( - "$submiturl?wizardnow=datasetitems", $question, $regenerate); + "{$submiturl}?wizardnow=datasetitems", $question, $regenerate); break; default: print_error('invalidwizardpage', 'question'); @@ -706,22 +706,22 @@ public function supports_dataset_item_generation() { 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('select', "calcdistribution[$idx]", + $mform->addElement('select', "calcdistribution[{$idx}]", get_string('calcdistribution', 'qtype_calculated'), $distriboptions); } @@ -730,11 +730,11 @@ public function custom_generator_set_data($datasetdefs, $formdata) { foreach ($datasetdefs as $datasetdef) { if (preg_match('~^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$~', $datasetdef->options, $regs)) { - $defid = "$datasetdef->type-$datasetdef->category-$datasetdef->name"; - $formdata["calcdistribution[$idx]"] = $regs[1]; - $formdata["calcmin[$idx]"] = $regs[2]; - $formdata["calcmax[$idx]"] = $regs[3]; - $formdata["calclength[$idx]"] = $regs[4]; + $defid = "{$datasetdef->type}-{$datasetdef->category}-{$datasetdef->name}"; + $formdata["calcdistribution[{$idx}]"] = $regs[1]; + $formdata["calcmin[{$idx}]"] = $regs[2]; + $formdata["calcmax[{$idx}]"] = $regs[3]; + $formdata["calclength[{$idx}]"] = $regs[4]; } $idx++; } @@ -745,7 +745,7 @@ public function custom_generator_tools($datasetdef) { global $OUTPUT; if (preg_match('~^(uniform|loguniform):([^:]*):([^:]*):([0-9]*)$~', $datasetdef->options, $regs)) { - $defid = "$datasetdef->type-$datasetdef->category-$datasetdef->name"; + $defid = "{$datasetdef->type}-{$datasetdef->category}-{$datasetdef->name}"; for ($i = 0; $i<10; ++$i) { $lengthoptions[$i] = get_string(($regs[1] == 'uniform' ? 'decimals' @@ -761,10 +761,10 @@ public function custom_generator_tools($datasetdef) { 'menucalcdistribution', false, array('class' => 'accesshide')); $menu2 .= html_writer::select($options, 'calcdistribution[]', $regs[1], null); return '
    ' . ' & & ' . $menu1 . '
    ' . $menu2; @@ -940,7 +940,7 @@ public function save_dataset_items($question, $fromform) { // Fix regenerate for this datadefs. $defregenerate = 0; if ($synchronize && - !empty ($fromform->nextpageparam["datasetregenerate[$datasetdef->name"])) { + !empty ($fromform->nextpageparam["datasetregenerate[{$datasetdef->name}"])) { $defregenerate = 1; } else if (!$synchronize && (($regenerate == 1 && $datasetdef->category == 0) ||$regenerate == 2)) { @@ -1075,7 +1075,7 @@ public function comment_on_datasetitems($qtypeobj, $questionid, $questiontext, } if ($answer->min === '') { // This should mean that something is wrong. - $comment->stranswers[$key] = " $formattedanswer->answer".'

    '; + $comment->stranswers[$key] = " {$formattedanswer->answer}".'

    '; } else if ($formula === '*') { $comment->stranswers[$key] = $formula . ' = ' . get_string('anyvalue', 'qtype_calculated') . '


    '; @@ -1130,7 +1130,7 @@ public function dataset_options($form, $name, $mandatory = true, } if (!$selected) { if ($mandatory) { - $selected = "1-0-$name"; // Default. + $selected = "1-0-{$name}"; // Default. } else { $selected = '0'; // Default. } @@ -1222,7 +1222,7 @@ public function get_dataset_definitions($questionid, $newdatasets) { ORDER BY i.id"; if ($records = $DB->get_records_sql($sql, array($questionid))) { foreach ($records as $r) { - $datasetdefs["$r->type-$r->category-$r->name"] = $r; + $datasetdefs["{$r->type}-{$r->category}-{$r->name}"] = $r; } } } @@ -1465,8 +1465,8 @@ public function dataset_options_from_database($form, $name, $prefix = '', $options['0'] = get_string($prefix.'nodataset', $langfile); // New question no local. if (!isset($form->id) || $form->id == 0) { - $key = "$type-0-$name"; - $options[$key] = get_string($prefix."newlocal$type", $langfile); + $key = "{$type}-0-{$name}"; + $options[$key] = get_string($prefix."newlocal{$type}", $langfile); $currentdatasetdef = new stdClass(); $currentdatasetdef->type = '0'; } else { @@ -1479,12 +1479,12 @@ public function dataset_options_from_database($form, $name, $prefix = '', $currentdatasetdef = new stdClass(); $currentdatasetdef->type = '0'; } - $key = "$type-0-$name"; + $key = "{$type}-0-{$name}"; if ($currentdatasetdef->type == $type and $currentdatasetdef->category == 0) { - $options[$key] = get_string($prefix."keptlocal$type", $langfile); + $options[$key] = get_string($prefix."keptlocal{$type}", $langfile); } else { - $options[$key] = get_string($prefix."newlocal$type", $langfile); + $options[$key] = get_string($prefix."newlocal{$type}", $langfile); } } // Construct question category options. @@ -1497,21 +1497,21 @@ public function dataset_options_from_database($form, $name, $prefix = '', AND a.category = ? AND a.name = ?", array($form->category, $name)); $type = 1; - $key = "$type-$form->category-$name"; + $key = "{$type}-{$form->category}-{$name}"; if (!empty($categorydatasetdefs)) { // There is at least one with the same name. if (isset($form->id) && isset($categorydatasetdefs[$form->id])) { // It is already used by this question. - $options[$key] = get_string($prefix."keptcategory$type", $langfile); + $options[$key] = get_string($prefix."keptcategory{$type}", $langfile); } else { - $options[$key] = get_string($prefix."existingcategory$type", $langfile); + $options[$key] = get_string($prefix."existingcategory{$type}", $langfile); } } else { - $options[$key] = get_string($prefix."newcategory$type", $langfile); + $options[$key] = get_string($prefix."newcategory{$type}", $langfile); } // All done! return array($options, $currentdatasetdef->type - ? "$currentdatasetdef->type-$currentdatasetdef->category-$name" + ? "{$currentdatasetdef->type}-{$currentdatasetdef->category}-{$name}" : ''); } @@ -1541,8 +1541,8 @@ public function get_dataset_definitions_category($form) { WHERE i.id = d.datasetdefinition AND i.category = ?"; if ($records = $DB->get_records_sql($sql, array($form->category))) { foreach ($records as $r) { - if (!isset ($datasetdefs["$r->name"])) { - $datasetdefs["$r->name"] = $r->itemcount; + if (!isset ($datasetdefs["{$r->name}"])) { + $datasetdefs["{$r->name}"] = $r->itemcount; } } } @@ -1578,14 +1578,14 @@ public function print_dataset_definitions_category($form) { $sql1 = "SELECT q.* FROM {question} q WHERE q.id = ?"; - if (!isset ($datasetdefs["$r->type-$r->category-$r->name"])) { - $datasetdefs["$r->type-$r->category-$r->name"] = $r; + if (!isset ($datasetdefs["{$r->type}-{$r->category}-{$r->name}"])) { + $datasetdefs["{$r->type}-{$r->category}-{$r->name}"] = $r; } if ($questionb = $DB->get_records_sql($sql1, array($r->question))) { - if (!isset ($datasetdefs["$r->type-$r->category-$r->name"]->questions[$r->question])) { - $datasetdefs["$r->type-$r->category-$r->name"]->questions[$r->question] = new stdClass(); + if (!isset ($datasetdefs["{$r->type}-{$r->category}-{$r->name}"]->questions[$r->question])) { + $datasetdefs["{$r->type}-{$r->category}-{$r->name}"]->questions[$r->question] = new stdClass(); } - $datasetdefs["$r->type-$r->category-$r->name"]->questions[ + $datasetdefs["{$r->type}-{$r->category}-{$r->name}"]->questions[ $r->question]->name = $questionb[$r->question]->name; } } @@ -1595,20 +1595,20 @@ public function print_dataset_definitions_category($form) { $text = " + scope=\"col\">{$namestr} + scope=\"col\">{$rangeofvaluestr} + scope=\"col\">{$itemscountstr} + scope=\"col\">{$questionusingstr}"; foreach ($datasetdefs as $datasetdef) { list($distribution, $min, $max, $dec) = explode(':', $datasetdef->options, 4); $text .= " - - - + + + "; } @@ -1653,7 +1653,7 @@ public function print_dataset_definitions_category_shared($question, $datasetdef WHERE i.id = d.datasetdefinition AND i.category = ?"; if ($records = $DB->get_records_sql($sql, array($category))) { foreach ($records as $r) { - $key = "$r->type-$r->category-$r->name"; + $key = "{$r->type}-{$r->category}-{$r->name}"; $sql1 = "SELECT q.* FROM {question} q WHERE q.id = ?"; @@ -1674,11 +1674,11 @@ public function print_dataset_definitions_category_shared($question, $datasetdef $text = "
    $namestr $rangeofvaluestr $itemscountstr $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 .= "
    "; + scope=\"col\">{$namestr}"; $text .= ""; + scope=\"col\">{$itemscountstr}"; $text .= ""; + scope=\"col\">  {$questionusingstr}   "; $text .= ""; $text .= " + align=\"center\" rowspan=\"{$count}\"> {$datasetdef->name} "; + 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 .= ""; } $line++; - $text .= ""; + $text .= ""; // 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 .= ""; - $text .= ""; + $text .= ""; $text .= "
    $namestr$itemscountstr  $questionusingstr   Quizquestions); $text .= "
    $datasetdef->name $datasetdef->itemcount
    $qu->name{$qu->name}$nbofquiz$nbofattempts"; + $text .= "{$nbofquiz}{$nbofattempts}"; } else { $text .= "0
    "; @@ -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 = '-+/*%>:^\~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}\n"; + $expout .= " <{$field}>{$exportedvalue}\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 . "\n"; + $expout .= " <{$extra}>" . $question->options->$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++; } }