diff --git a/mod/quiz/attempt.php b/mod/quiz/attempt.php index d2f663e3401..6b823757e0f 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))) { @@ -165,7 +165,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); @@ -177,11 +177,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 7d3512d51b7..f06cc70867b 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;