Merging fix for MDL-11900 from MOODLE_19_STABLE
authormark-nielsen <mark-nielsen>
Sat, 29 Dec 2007 21:50:53 +0000 (21:50 +0000)
committermark-nielsen <mark-nielsen>
Sat, 29 Dec 2007 21:50:53 +0000 (21:50 +0000)
mod/lesson/action/continue.php

index 3b5aa19dcf453da561973949d416428076e1eb52..05d6cb312e918dc5aa8df0c414ae6a8e9883b88d 100644 (file)
                 $nhits = 0;
                 $correctresponse = '';
                 $wrongresponse = '';
+                $correctanswerid = 0;
+                $wronganswerid = 0;
                 // store student's answers for displaying on feedback page
                 foreach ($answers as $answer) {
                     foreach ($useranswers as $key => $answerid) {
                                 // leave in its "raw" state - will converted into a proper page id later
                                 $correctpageid = $answer->jumpto;
                             }
+                            // save the answer id for scoring
+                            if ($correctanswerid == 0) {
+                                $correctanswerid = $answer->id;
+                            }
                             // ...also save any response from the correct answers...
                             if (trim(strip_tags($answer->response))) {
                                 $correctresponse = $answer->response;
                                 // leave in its "raw" state - will converted into a proper page id later
                                 $wrongpageid = $answer->jumpto;
                             }
+                            // save the answer id for scoring
+                            if ($wronganswerid == 0) {
+                                $wronganswerid = $answer->id;
+                            }
                             // ...and from the incorrect ones, don't know which to use at this stage
                             if (trim(strip_tags($answer->response))) {
                                 $wrongresponse = $answer->response;
                                 // leave in its "raw" state - will converted into a proper page id later
                                 $correctpageid = $answer->jumpto;
                             }
+                            // save the answer id for scoring
+                            if ($correctanswerid == 0) {
+                                $correctanswerid = $answer->id;
+                            }
                             // ...also save any response from the correct answers...
                             if (trim(strip_tags($answer->response))) {
                                 $correctresponse = $answer->response;
                                 // leave in its "raw" state - will converted into a proper page id later
                                 $wrongpageid = $answer->jumpto;
                             }
+                            // save the answer id for scoring
+                            if ($wronganswerid == 0) {
+                                $wronganswerid = $answer->id;
+                            }
                             // ...and from the incorrect ones, don't know which to use at this stage
                             if (trim(strip_tags($answer->response))) {
                                 $wrongresponse = $answer->response;
                     $correctanswer = true;
                     $response  = $correctresponse;
                     $newpageid = $correctpageid;
+                    $answerid  = $correctanswerid;
                 } else {
                     $response  = $wrongresponse;
                     $newpageid = $wrongpageid;
+                    $answerid  = $wronganswerid;
                 }
             } else {
                 // only one answer allowed