Permalink
Browse files

fix notices: MDL-15974 Some systems that were upgraded have nullable …

…columns, leading to notices

A new install has NOT NULL DEFAULT 0.
  • Loading branch information...
tjhunt
tjhunt committed Nov 27, 2008
1 parent 4baced6 commit 8b28857e692d182c70cc3f8b44e5beefa8256e97
Showing with 11 additions and 11 deletions.
  1. +4 −4 lib/weblib.php
  2. +6 −6 mod/quiz/attempt.php
  3. +1 −1 question/type/multichoice/questiontype.php
View
@@ -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
View
@@ -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);
}
@@ -164,7 +164,7 @@ function create_session_and_responses(&$question, &$state, $cmoptions, $attempt)
$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;

0 comments on commit 8b28857

Please sign in to comment.