From c0f177f19cff8e83c2af8d36416255372d18f02d Mon Sep 17 00:00:00 2001 From: Rossiani Wijaya Date: Fri, 10 May 2013 11:14:52 +0800 Subject: [PATCH] MDL-39488: Lesson Module: Fixed the potential variable overwritting for answers --- mod/lesson/pagetypes/matching.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mod/lesson/pagetypes/matching.php b/mod/lesson/pagetypes/matching.php index a2692387ae9..3c77e53d0ef 100644 --- a/mod/lesson/pagetypes/matching.php +++ b/mod/lesson/pagetypes/matching.php @@ -161,16 +161,17 @@ class lesson_page_type_matching extends lesson_page { } $response = $data->response; - $answers = $this->get_answers(); + $getanswers = $this->get_answers(); - $correct = array_shift($answers); - $wrong = array_shift($answers); + $correct = array_shift($getanswers); + $wrong = array_shift($getanswers); - foreach ($answers as $key=>$answer) { + $answers = array(); + foreach ($getanswers as $key=>$answer) { if ($answer->answer !== '' or $answer->response !== '') { $answers[$answer->id] = $answer; } - unset($answers[$key]); + unset($getanswers[$key]); } // get the user's exact responses for record keeping $hits = 0;