Permalink
Browse files

MDL-39488 Lesson Module: Improve code performance

  • Loading branch information...
1 parent 51fce0f commit 3b3e7fd11c56ca27c45f041c5d3355b46432f52b @rwijaya rwijaya committed May 8, 2013
Showing with 4 additions and 8 deletions.
  1. +4 −8 mod/lesson/pagetypes/matching.php
@@ -161,14 +161,6 @@ public function check_answer() {
}
$response = $data->response;
-
- foreach ($response as $resp) {
- if ($resp == '') {
- $result->noanswer = true;
- return $result;
- }
- }
-
$answers = $this->get_answers();
$correct = array_shift($answers);
@@ -184,6 +176,10 @@ public function check_answer() {
$hits = 0;
$userresponse = array();
foreach ($response as $id => $value) {
+ if ($value == '') {
+ $result->noanswer = true;
+ return $result;
+ }
$userresponse[] = $value;
// Make sure the user's answer exists in question's answer
if (array_key_exists($id, $answers)) {

0 comments on commit 3b3e7fd

Please sign in to comment.