fix notices: MDL-15974 Some systems that were upgraded have nullable columns, leading to notices
A new install has NOT NULL DEFAULT 0.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user