mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 12:45:04 +01:00
Merge branch 'MDL-49368' of git://github.com/timhunt/moodle
This commit is contained in:
commit
28887344d6
@ -26,6 +26,8 @@ $string['answer'] = 'Answer {$a}';
|
||||
$string['availablechoices'] = 'Available choices';
|
||||
$string['blanksforxmorequestions'] = 'Blanks for {no} more questions';
|
||||
$string['correctansweris'] = 'The correct answer is: {$a}';
|
||||
$string['deletedchoice'] = '[Deleted choice]';
|
||||
$string['deletedsubquestion'] = 'This part of the question was deleted after the attempt was started.';
|
||||
$string['filloutthreeqsandtwoas'] = 'You must provide at least two questions and three answers. You can provide extra wrong answers by giving an answer with a blank question. Entries where both the question and the answer are blank will be ignored.';
|
||||
$string['nomatchinganswer'] = 'You must specify an answer matching the question \'{$a}\'.';
|
||||
$string['nomatchinganswerforq'] = 'You must specify an answer for this question.';
|
||||
|
@ -71,6 +71,25 @@ class qtype_match_question extends question_graded_automatically_with_countback
|
||||
public function apply_attempt_state(question_attempt_step $step) {
|
||||
$this->stemorder = explode(',', $step->get_qt_var('_stemorder'));
|
||||
$this->set_choiceorder(explode(',', $step->get_qt_var('_choiceorder')));
|
||||
|
||||
// Add any missing subquestions. Sometimes people edit questions after they
|
||||
// have been attempted which breaks things.
|
||||
foreach ($this->stemorder as $stemid) {
|
||||
if (!isset($this->stems[$stemid])) {
|
||||
$this->stems[$stemid] = html_writer::span(
|
||||
get_string('deletedsubquestion', 'qtype_match'), 'notifyproblem');
|
||||
$this->stemformat[$stemid] = FORMAT_HTML;
|
||||
$this->right[$stemid] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Add any missing choices. Sometimes people edit questions after they
|
||||
// have been attempted which breaks things.
|
||||
foreach ($this->choiceorder as $choiceid) {
|
||||
if (!isset($this->choices[$choiceid])) {
|
||||
$this->choices[$choiceid] = get_string('deletedchoice', 'qtype_match');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,8 +99,8 @@ class qtype_match_question extends question_graded_automatically_with_countback
|
||||
*/
|
||||
protected function set_choiceorder($choiceorder) {
|
||||
$this->choiceorder = array();
|
||||
foreach ($choiceorder as $key => $value) {
|
||||
$this->choiceorder[$key + 1] = $value;
|
||||
foreach ($choiceorder as $key => $choiceid) {
|
||||
$this->choiceorder[$key + 1] = $choiceid;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,9 @@ class qtype_match_renderer extends qtype_with_combined_feedback_renderer {
|
||||
$choices = $this->format_choices($question);
|
||||
$right = array();
|
||||
foreach ($stemorder as $key => $stemid) {
|
||||
if (!isset($choices[$question->get_right_choice_for($stemid)])) {
|
||||
continue;
|
||||
}
|
||||
$right[] = $question->make_html_inline($this->format_stem_text($qa, $stemid)) . ' – ' .
|
||||
$choices[$question->get_right_choice_for($stemid)];
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ $string['choices'] = 'Available choices';
|
||||
$string['clozeaid'] = 'Enter missing word';
|
||||
$string['correctansweris'] = 'The correct answer is: {$a}';
|
||||
$string['correctfeedback'] = 'For any correct response';
|
||||
$string['deletedchoice'] = 'This choice was deleted after the attempt was started.';
|
||||
$string['errgradesetanswerblank'] = 'Grade set, but the Answer is blank';
|
||||
$string['errfractionsaddwrong'] = 'The positive grades you have chosen do not add up to 100%<br />Instead, they add up to {$a}%';
|
||||
$string['errfractionsnomax'] = 'One of the choices should be 100%, so that it is<br />possible to get a full grade for this question.';
|
||||
|
@ -64,6 +64,24 @@ abstract class qtype_multichoice_base extends question_graded_automatically {
|
||||
|
||||
public function apply_attempt_state(question_attempt_step $step) {
|
||||
$this->order = explode(',', $step->get_qt_var('_order'));
|
||||
|
||||
// Add any missing answers. Sometimes people edit questions after they
|
||||
// have been attempted which breaks things.
|
||||
foreach ($this->order as $ansid) {
|
||||
if (isset($this->answers[$ansid])) {
|
||||
continue;
|
||||
}
|
||||
$a = new stdClass();
|
||||
$a->id = 0;
|
||||
$a->answer = html_writer::span(get_string('deletedchoice', 'qtype_multichoice'),
|
||||
'notifyproblem');
|
||||
$a->answerformat = FORMAT_HTML;
|
||||
$a->fraction = 0;
|
||||
$a->feedback = '';
|
||||
$a->feedbackformat = FORMAT_HTML;
|
||||
$this->answers[$ansid] = $this->qtype->make_answer($a);
|
||||
$this->answers[$ansid]->answerformat = FORMAT_HTML;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_question_summary() {
|
||||
|
@ -174,6 +174,11 @@ class qtype_multichoice extends question_type {
|
||||
$this->initialise_question_answers($question, $questiondata, false);
|
||||
}
|
||||
|
||||
public function make_answer($answer) {
|
||||
// Overridden just so we can make it public for use by question.php.
|
||||
return parent::make_answer($answer);
|
||||
}
|
||||
|
||||
public function delete_question($questionid, $contextid) {
|
||||
global $DB;
|
||||
$DB->delete_records('qtype_multichoice_options', array('questionid' => $questionid));
|
||||
|
Loading…
x
Reference in New Issue
Block a user