Permalink
Browse files

MDL-39488: Lesson Module: Fixed the potential variable overwritting f…

…or answers
  • Loading branch information...
1 parent 3b3e7fd commit 89aa433fbd769f19a043a730af3657f269023d74 Rossiani Wijaya committed May 10, 2013
Showing with 6 additions and 5 deletions.
  1. +6 −5 mod/lesson/pagetypes/matching.php
@@ -161,16 +161,17 @@ public function check_answer() {
}
$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;

0 comments on commit 89aa433

Please sign in to comment.