From d19d9ef16d53b2b5273bd390f7880e074719bb9b Mon Sep 17 00:00:00 2001 From: michaelpenne Date: Tue, 21 Sep 2004 22:11:00 +0000 Subject: [PATCH] Fixed some problems with matching --- mod/lesson/lesson.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mod/lesson/lesson.php b/mod/lesson/lesson.php index fcdac3f648..0cb3c30b31 100644 --- a/mod/lesson/lesson.php +++ b/mod/lesson/lesson.php @@ -981,6 +981,12 @@ $ncorrect = 0; $i = 0; foreach ($answers as $answer) { + if ($i == 0 || $i == 1) { + // ignore first two answers, they are correct response + // and wrong response + $i++; + continue; + } if ($answer->response == $response[$answer->id]) { $ncorrect++; } @@ -994,7 +1000,7 @@ } $i++; } - if ($ncorrect == count($answers)) { + if ($ncorrect == count($answers)-2) { // dont count correct/wrong responses in the total. $response = get_string("thatsthecorrectanswer", "lesson"); foreach ($answers as $answer) { if ($answer->response == NULL && $answer->answer != NULL) { @@ -2007,6 +2013,10 @@ error("Insert Page: answer record $i not inserted"); } } else { + if ($form->qtype == LESSON_MATCHING) { + // need to add two to offset correct response and wrong response + $lesson->maxanswers = $lesson->maxanswers + 2; + } for ($i = 0; $i < $lesson->maxanswers; $i++) { if (trim(strip_tags($form->answer[$i]))) { // strip_tags because the HTML editor adds


... $newanswer->lessonid = $lesson->id; @@ -2253,6 +2263,10 @@ } } else { // it's an "ordinary" page + if ($form->qtype == LESSON_MATCHING) { + // need to add two to offset correct response and wrong response + $lesson->maxanswers = $lesson->maxanswers + 2; + } for ($i = 0; $i < $lesson->maxanswers; $i++) { // strip tags because the editor gives


... // also save any answers where the editor is (going to be) used -- 2.39.5