[Fix] Notices were being printed in PHP5 for NULL objects. Checking for NULL now before using in multichoice and truefalse questions

This commit is contained in:
mark-nielsen 2006-04-27 16:48:38 +00:00
parent 066c0af9bf
commit 718dbada67

View File

@ -508,7 +508,11 @@
case LESSON_MULTICHOICE:
case LESSON_TRUEFALSE:
if ($page->qoption) {
$userresponse = explode(",", $useranswer->useranswer);
if ($useranswer == NULL) {
$userresponse = array();
} else {
$userresponse = explode(",", $useranswer->useranswer);
}
if (in_array($answer->id, $userresponse)) {
// make checked
$data = "<input readonly=\"readonly\" disabled=\"disabled\" name=\"answer[$i]\" checked=\"checked\" type=\"checkbox\" value=\"1\" />";
@ -542,7 +546,7 @@
$data .= format_text($answer->answer,FORMAT_MOODLE,$formattextdefoptions);
}
} else {
if ($answer->id == $useranswer->answerid) {
if ($useranswer != NULL and $answer->id == $useranswer->answerid) {
// make checked
$data = "<input readonly=\"readonly\" disabled=\"disabled\" name=\"answer[$i]\" checked=\"checked\" type=\"checkbox\" value=\"1\" />";
if ($answer->response == NULL) {