Skip to content
Browse files

[Fix] Notices were being printed in PHP5 for NULL objects. Checking f…

…or NULL now before using in multichoice and truefalse questions
  • Loading branch information...
1 parent 066c0af commit 718dbada67e47b7eff9de3969b96f24bfb09d3a8 mark-nielsen committed Apr 27, 2006
Showing with 6 additions and 2 deletions.
  1. +6 −2 mod/lesson/report.php
View
8 mod/lesson/report.php
@@ -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) {

0 comments on commit 718dbad

Please sign in to comment.
Something went wrong with that request. Please try again.