MDL-46212 questions: add {} whenver vars are put into "" strings
Having had one subtle bug cased be this, I decided to do a search and fix all of these.
This commit is contained in:
@@ -1072,9 +1072,9 @@ class qformat_xml extends qformat_default {
|
||||
$raw = $this->xml_escape($raw);
|
||||
|
||||
if ($short) {
|
||||
$xml = "$indent<text>$raw</text>\n";
|
||||
$xml = "{$indent}<text>{$raw}</text>\n";
|
||||
} else {
|
||||
$xml = "$indent<text>\n$raw\n$indent</text>\n";
|
||||
$xml = "{$indent}<text>\n{$raw}\n{$indent}</text>\n";
|
||||
}
|
||||
|
||||
return $xml;
|
||||
@@ -1137,7 +1137,7 @@ class qformat_xml extends qformat_default {
|
||||
$expout = '';
|
||||
|
||||
// Add a comment linking this to the original question id.
|
||||
$expout .= "<!-- question: $question->id -->\n";
|
||||
$expout .= "<!-- question: {$question->id} -->\n";
|
||||
|
||||
// Check question type.
|
||||
$questiontype = $this->get_qtype($question->qtype);
|
||||
@@ -1147,7 +1147,7 @@ class qformat_xml extends qformat_default {
|
||||
$categorypath = $this->writetext($question->category);
|
||||
$expout .= " <question type=\"category\">\n";
|
||||
$expout .= " <category>\n";
|
||||
$expout .= " $categorypath\n";
|
||||
$expout .= " {$categorypath}\n";
|
||||
$expout .= " </category>\n";
|
||||
$expout .= " </question>\n";
|
||||
return $expout;
|
||||
@@ -1155,7 +1155,7 @@ class qformat_xml extends qformat_default {
|
||||
|
||||
// Now we know we are are handing a real question.
|
||||
// Output the generic information.
|
||||
$expout .= " <question type=\"$questiontype\">\n";
|
||||
$expout .= " <question type=\"{$questiontype}\">\n";
|
||||
$expout .= " <name>\n";
|
||||
$expout .= $this->writetext($question->name, 3);
|
||||
$expout .= " </name>\n";
|
||||
@@ -1209,7 +1209,7 @@ class qformat_xml extends qformat_default {
|
||||
case 'numerical':
|
||||
foreach ($question->options->answers as $answer) {
|
||||
$expout .= $this->write_answer($answer,
|
||||
" <tolerance>$answer->tolerance</tolerance>\n");
|
||||
" <tolerance>{$answer->tolerance}</tolerance>\n");
|
||||
}
|
||||
|
||||
$units = $question->options->units;
|
||||
@@ -1333,7 +1333,7 @@ class qformat_xml extends qformat_default {
|
||||
|
||||
foreach ($question->options->answers as $answer) {
|
||||
$percent = 100 * $answer->fraction;
|
||||
$expout .= "<answer fraction=\"$percent\">\n";
|
||||
$expout .= "<answer fraction=\"{$percent}\">\n";
|
||||
// The "<text/>" tags are an added feature, old files won't have them.
|
||||
$expout .= " <text>{$answer->answer}</text>\n";
|
||||
$expout .= " <tolerance>{$answer->tolerance}</tolerance>\n";
|
||||
@@ -1412,7 +1412,7 @@ class qformat_xml extends qformat_default {
|
||||
"</maximum>\n";
|
||||
$expout .= " <decimals>" . $this->writetext($def->decimals) .
|
||||
"</decimals>\n";
|
||||
$expout .= " <itemcount>$def->itemcount</itemcount>\n";
|
||||
$expout .= " <itemcount>{$def->itemcount}</itemcount>\n";
|
||||
if ($def->itemcount > 0) {
|
||||
$expout .= " <dataset_items>\n";
|
||||
foreach ($def->items as $item) {
|
||||
@@ -1479,7 +1479,7 @@ class qformat_xml extends qformat_default {
|
||||
public function write_answer($answer, $extra = '') {
|
||||
$percent = $answer->fraction * 100;
|
||||
$output = '';
|
||||
$output .= " <answer fraction=\"$percent\" {$this->format($answer->answerformat)}>\n";
|
||||
$output .= " <answer fraction=\"{$percent}\" {$this->format($answer->answerformat)}>\n";
|
||||
$output .= $this->writetext($answer->answer, 3);
|
||||
$output .= $this->write_files($answer->answerfiles);
|
||||
$output .= " <feedback {$this->format($answer->feedbackformat)}>\n";
|
||||
|
||||
Reference in New Issue
Block a user