Merge branch 'MDL-66115_master' of https://github.com/dvdcastro/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2019-07-17 23:08:53 +02:00
4 changed files with 22 additions and 2 deletions
@@ -70,3 +70,4 @@ $string['summarisechoiceno'] = 'Item {$a}';
$string['summariseplaceno'] = 'Drop zone {$a}';
$string['xleft'] = 'Left';
$string['ytop'] = 'Top';
$string['deletedchoice'] = '[Deleted choice]';
+5 -1
View File
@@ -62,7 +62,11 @@ class qtype_ddtoimage_question_base extends qtype_gapselect_question_base {
$response[$this->field($placeno)]) {
$selected = $this->get_selected_choice($place->group,
$response[$this->field($placeno)]);
$summarisechoice = $selected->summarise();
if (isset($selected)) {
$summarisechoice = $selected->summarise();
} else {
$summarisechoice = get_string('deletedchoice', 'qtype_ddimageortext');
}
$allblank = false;
} else {
$summarisechoice = '';
@@ -266,4 +266,19 @@ class qtype_ddimageortext_question_test extends basic_testcase {
4 => new question_classified_response(4, '4. dog', 1)
), $dd->classify_response(array('p1' => '', 'p2' => '1', 'p3' => '2', 'p4' => '2')));
}
public function test_summarise_response_choice_deleted() {
/** @var qtype_ddtoimage_question_base $dd */
$dd = test_question_maker::make_question('ddimageortext');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
// Simulation of an instructor deleting 1 choice after an attempt has been made.
unset($dd->choices[1][1]);
$delquestionstr = get_string('deletedchoice', 'qtype_ddimageortext');
$this->assertEquals("Drop zone 1 -> {{$delquestionstr}} ".
"Drop zone 2 -> {{$delquestionstr}} ".
'Drop zone 3 -> {3. lazy} '.
'Drop zone 4 -> {3. lazy}',
$dd->summarise_response(array('p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1')));
}
}
+1 -1
View File
@@ -127,7 +127,7 @@ abstract class qtype_gapselect_question_base extends question_graded_automatical
protected function get_selected_choice($group, $shuffledchoicenumber) {
$choiceno = $this->choiceorder[$group][$shuffledchoicenumber];
return $this->choices[$group][$choiceno];
return isset($this->choices[$group][$choiceno]) ? $this->choices[$group][$choiceno] : null;
}
public function summarise_response(array $response) {