From 1130c181f95effbff024a3cbd78033f57af6db31 Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Fri, 23 May 2014 23:08:36 +0200 Subject: [PATCH] MDL-45686 qtype_multichoice get_num_selected_choices return wrong result --- question/type/multichoice/question.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/question/type/multichoice/question.php b/question/type/multichoice/question.php index 58a21364bed..c73969c2588 100644 --- a/question/type/multichoice/question.php +++ b/question/type/multichoice/question.php @@ -414,7 +414,8 @@ class qtype_multichoice_multi_question extends qtype_multichoice_base { public function get_num_selected_choices(array $response) { $numselected = 0; foreach ($response as $key => $value) { - if (!empty($value)) { + // Response keys starting with _ are internal values like _order, so ignore them. + if (!empty($value) && $key[0] != '_') { $numselected += 1; } }