diff --git a/question/type/ddimageortext/questionbase.php b/question/type/ddimageortext/questionbase.php index 6c75098985c..38b1a96eadd 100644 --- a/question/type/ddimageortext/questionbase.php +++ b/question/type/ddimageortext/questionbase.php @@ -122,8 +122,12 @@ class qtype_ddtoimage_question_base extends qtype_gapselect_question_base { $choice = $this->choices[$group][$choiceno]; $correct = $this->get_right_choice_for($placeno) == $response[$fieldname]; - $parts[$placeno] = new question_classified_response( - $choiceno, $choice->summarise(), $correct?1:0); + if ($correct) { + $grade = 1; + } else { + $grade = 0; + } + $parts[$placeno] = new question_classified_response($choiceno, $choice->summarise(), $grade); } return $parts; } diff --git a/question/type/ddimageortext/questiontypebase.php b/question/type/ddimageortext/questiontypebase.php index 7acfca73cd0..2512852da0d 100644 --- a/question/type/ddimageortext/questiontypebase.php +++ b/question/type/ddimageortext/questiontypebase.php @@ -60,7 +60,7 @@ class qtype_ddtoimage_base extends question_type { $this->initialise_combined_feedback($question, $questiondata, true); $question->choices = array(); - $choiceindexmap= array(); + $choiceindexmap = array(); // Store the choices in arrays by group. foreach ($questiondata->options->drags as $dragdata) { @@ -165,18 +165,11 @@ class qtype_ddtoimage_base extends question_type { $parts = array(); foreach ($question->places as $placeno => $place) { - $group = $place->group; $choices = array(); - foreach ($question->choices[$group] as $i => $choice) { - $summarisechoice = $choice->summarise(); - + foreach ($question->choices[$place->group] as $i => $choice) { $correct = $question->rightchoices[$placeno] == $i; - if ($correct) { - $choices[$choice->no] = new question_possible_response( - $summarisechoice, - $correct?1:0); - } + $choices[$choice->no] = new question_possible_response($choice->summarise(), $correct ? 1 : 0); } $choices[null] = question_possible_response::no_response();