$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