MDL-37172 Hardcoded strings in some question imports formats
AMOS BEGIN CPY [unknownorunhandledtype,qformat_blackboard_six],[unknownorunhandledtype,question] AMOS END
This commit is contained in:
@@ -413,6 +413,7 @@ $string['technicalinfoquestionsummary'] = 'Question summary: {$a}';
|
||||
$string['technicalinforightsummary'] = 'Right answer summary: {$a}';
|
||||
$string['technicalinfostate'] = 'Question state: {$a}';
|
||||
$string['unknownbehaviour'] = 'Unknown behaviour: {$a}.';
|
||||
$string['unknownorunhandledtype'] = 'Unknown or unhandled question type: {$a}';
|
||||
$string['unknownquestion'] = 'Unknown question: {$a}.';
|
||||
$string['unknownquestioncatregory'] = 'Unknown question category: {$a}.';
|
||||
$string['unknownquestiontype'] = 'Unknown question type: {$a}.';
|
||||
|
||||
@@ -87,7 +87,7 @@ class qformat_blackboard_six_qti extends qformat_blackboard_six_base {
|
||||
$this->process_essay($question, $questions);
|
||||
break;
|
||||
default:
|
||||
$this->error(get_string('unknownorunhandledtype', 'qformat_blackboard_six', $question->qtype));
|
||||
$this->error(get_string('unknownorunhandledtype', 'question', $question->qtype));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,7 @@ class qformat_examview extends qformat_based_on_xml {
|
||||
}
|
||||
|
||||
public function readquestion($qrec) {
|
||||
global $OUTPUT;
|
||||
|
||||
$type = trim($qrec['@']['type']);
|
||||
$question = $this->defaultquestion();
|
||||
@@ -224,7 +225,7 @@ class qformat_examview extends qformat_based_on_xml {
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
print("<p>Question type ".$type." import not supported for ".$question->questiontext."<p>");
|
||||
echo $OUTPUT->notification(get_string('unknownorunhandledtype', 'question', $type));
|
||||
$question = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,8 @@ class qformat_learnwise extends qformat_default {
|
||||
}
|
||||
|
||||
function readquestion($lines) {
|
||||
global $OUTPUT;
|
||||
|
||||
$text = implode(' ', $lines);
|
||||
$text = str_replace(array('\t','\n','\r','\''), array('','','','\\\''), $text);
|
||||
|
||||
@@ -121,7 +123,7 @@ class qformat_learnwise extends qformat_default {
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "<p>I don't understand this question type (type = <strong>$type</strong>).</p>\n";
|
||||
echo $OUTPUT->notification(get_string('unknownorunhandledtype', 'question', $type));
|
||||
}
|
||||
|
||||
$question = $this->defaultquestion();
|
||||
|
||||
@@ -70,28 +70,23 @@ class qformat_missingword extends qformat_default {
|
||||
|
||||
$answerstart = strpos($text, "{");
|
||||
if ($answerstart === false) {
|
||||
if ($this->displayerrors) {
|
||||
echo "<p>$text<p>Could not find a {";
|
||||
}
|
||||
$this->error(get_string('beginanswernotfound', 'qformat_missingword'), $text);
|
||||
return false;
|
||||
}
|
||||
|
||||
$answerfinish = strpos($text, "}");
|
||||
if ($answerfinish === false) {
|
||||
if ($this->displayerrors) {
|
||||
echo "<p>$text<p>Could not find a }";
|
||||
}
|
||||
$this->error(get_string('endanswernotfound', 'qformat_missingword'), $text);
|
||||
return false;
|
||||
}
|
||||
|
||||
$answerlength = $answerfinish - $answerstart;
|
||||
$answertext = substr($text, $answerstart + 1, $answerlength - 1);
|
||||
|
||||
/// Save the new question text
|
||||
// Save the new question text.
|
||||
$question->questiontext = substr_replace($text, "_____", $answerstart, $answerlength+1);
|
||||
$question->name = $this->create_default_question_name($question->questiontext, get_string('questionname', 'question'));
|
||||
|
||||
|
||||
/// Parse the answers
|
||||
$answertext = str_replace("=", "~=", $answertext);
|
||||
$answers = explode("~", $answertext);
|
||||
@@ -105,10 +100,8 @@ class qformat_missingword extends qformat_default {
|
||||
$countanswers = count($answers);
|
||||
|
||||
switch ($countanswers) {
|
||||
case 0: // invalid question
|
||||
if ($this->displayerrors) {
|
||||
echo "<p>No answers found in $answertext";
|
||||
}
|
||||
case 0: // Invalid question.
|
||||
$this->error(get_string('noanswerfound', 'qformat_missingword'), $answertext);
|
||||
return false;
|
||||
|
||||
case 1:
|
||||
@@ -120,13 +113,16 @@ class qformat_missingword extends qformat_default {
|
||||
}
|
||||
$question->answer[] = $answer;
|
||||
$question->fraction[] = 1;
|
||||
$question->feedback[] = "";
|
||||
$question->feedback[] = array('text' => '', 'format' => FORMAT_HTML);
|
||||
|
||||
return $question;
|
||||
|
||||
default:
|
||||
$question->qtype = MULTICHOICE;
|
||||
|
||||
$question = $this->add_blank_combined_feedback($question);
|
||||
$question->single = 1; // Only one answer allowed.
|
||||
|
||||
foreach ($answers as $key => $answer) {
|
||||
$answer = trim($answer);
|
||||
|
||||
@@ -166,8 +162,8 @@ class qformat_missingword extends qformat_default {
|
||||
# $question->fraction[$key] = 0;
|
||||
$question->fraction[$key] = $answeight;
|
||||
}
|
||||
$question->answer[$key] = $answer;
|
||||
$question->feedback[$key] = $comment;
|
||||
$question->answer[$key] = array('text' => $answer, 'format' => FORMAT_HTML);
|
||||
$question->feedback[$key] = array('text' => $comment, 'format' => FORMAT_HTML);
|
||||
}
|
||||
|
||||
return $question;
|
||||
|
||||
@@ -26,3 +26,6 @@
|
||||
$string['pluginname'] = 'Missing word format';
|
||||
$string['pluginname_help'] = 'Missing word format enables questions to be imported via text file.';
|
||||
$string['pluginname_link'] = 'Missing word format';
|
||||
$string['beginanswernotfound'] = 'Could not find a required "{" character in imported file content.';
|
||||
$string['endanswernotfound'] = 'Could not find a required "}" character in imported file content.';
|
||||
$string['noanswerfound'] = 'No answers found in question';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
As soon as we begin to explore our body parts as infants
|
||||
we become students of {=anatomy and physiology ~reflexology
|
||||
~science ~experiment}, and in a sense we remain students for life.
|
||||
@@ -0,0 +1,2 @@
|
||||
You can use the missing word format to import questions
|
||||
into both Moodle's Question bank and {=Lesson} activity.
|
||||
@@ -0,0 +1,2 @@
|
||||
This is {=the best answer#comment on the best answer ~75%a good
|
||||
answer#comment on the good answer ~a wrong one#comment on the bad answer}
|
||||
@@ -137,10 +137,8 @@ class qformat_xhtml extends qformat_default {
|
||||
case DESCRIPTION:
|
||||
break;
|
||||
case MULTIANSWER:
|
||||
$expout .= "<!-- CLOZE type is not supported -->\n";
|
||||
break;
|
||||
default:
|
||||
echo $OUTPUT->notification("No handler for qtype $question->qtype for GIFT export" );
|
||||
$expout .= "<!-- export of $question->qtype type is not supported -->\n";
|
||||
}
|
||||
// close off div
|
||||
$expout .= "</div>\n\n\n";
|
||||
|
||||
Reference in New Issue
Block a user