From 8b28857e692d182c70cc3f8b44e5beefa8256e97 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 27 Nov 2008 05:07:36 +0000 Subject: [PATCH] fix notices: MDL-15974 Some systems that were upgraded have nullable columns, leading to notices A new install has NOT NULL DEFAULT 0. --- lib/weblib.php | 8 ++++---- mod/quiz/attempt.php | 12 ++++++------ question/type/multichoice/questiontype.php | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index d7511148939..af66fd0ca72 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -3491,10 +3491,10 @@ function print_user_picture($user, $courseid, $picture=NULL, $size=0, $return=fa } else { $wwwroot = $CFG->wwwroot; } - - if (is_null($picture)) { - $picture = $user->picture; - } + + if (is_null($picture) and !empty($user->picture)) { + $picture = $user->picture; + } if ($picture) { // Print custom user picture if ($CFG->slasharguments) { // Use this method if possible for better caching diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index b4345a80646..1b8b6e1c8b2 100644 --- a/mod/quiz/attempt.php +++ b/mod/quiz/attempt.php @@ -118,12 +118,12 @@ $numberofpreviousattempts = count_records_select('quiz_attempts', "quiz = '{$quiz->id}' AND " . "userid = '{$USER->id}' AND timefinish > 0 AND preview != 1"); - if ($quiz->attempts and $numberofpreviousattempts >= $quiz->attempts) { + if (!empty($quiz->attempts) and $numberofpreviousattempts >= $quiz->attempts) { error(get_string('nomoreattempts', 'quiz'), "view.php?id={$cm->id}"); } /// Check subnet access - if ($quiz->subnet and !address_in_subnet(getremoteaddr(), $quiz->subnet)) { + if (!empty($quiz->subnet) and !address_in_subnet(getremoteaddr(), $quiz->subnet)) { if ($isteacher) { notify(get_string('subnetnotice', 'quiz')); } else { @@ -132,7 +132,7 @@ } /// Check password access - if ($quiz->password and empty($_POST['q'])) { + if (!empty($quiz->password) and empty($_POST['q'])) { if (empty($_POST['quizpassword'])) { if (trim(strip_tags($quiz->intro))) { @@ -167,7 +167,7 @@ } } - if ($quiz->delay1 or $quiz->delay2) { + if (!empty($quiz->delay1) or !empty($quiz->delay2)) { //quiz enforced time delay if ($attempts = quiz_get_user_attempts($quiz->id, $USER->id)) { $numattempts = count($attempts); @@ -179,11 +179,11 @@ if ($lastattempt_obj) { $lastattempt = $lastattempt_obj->timefinish; } - if ($numattempts == 1 && $quiz->delay1) { + if ($numattempts == 1 && !empty($quiz->delay1)) { if ($timenow - $quiz->delay1 < $lastattempt) { error(get_string('timedelay', 'quiz'), 'view.php?q='.$quiz->id); } - } else if($numattempts > 1 && $quiz->delay2) { + } else if($numattempts > 1 && !empty($quiz->delay2)) { if ($timenow - $quiz->delay2 < $lastattempt) { error(get_string('timedelay', 'quiz'), 'view.php?q='.$quiz->id); } diff --git a/question/type/multichoice/questiontype.php b/question/type/multichoice/questiontype.php index 36e19b75ad8..4e4ee6656b3 100644 --- a/question/type/multichoice/questiontype.php +++ b/question/type/multichoice/questiontype.php @@ -164,7 +164,7 @@ class question_multichoice_qtype extends default_questiontype { $answerids = array_values(array_map(create_function('$val', 'return $val->id;'), $question->options->answers)); // Shuffle the answers if required - if ($cmoptions->shuffleanswers and $question->options->shuffleanswers) { + if (!empty($cmoptions->shuffleanswers) and !empty($question->options->shuffleanswers)) { $answerids = swapshuffle($answerids); } $state->options->order = $answerids;