From 35a553661bc8d5a7569bdd6d2e551a443e20df9a Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Fri, 28 Apr 2017 15:28:42 +1200 Subject: [PATCH] set default values a bit better. --- classes/structure.php | 1 + sessions.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/structure.php b/classes/structure.php index 8064f50..3506217 100644 --- a/classes/structure.php +++ b/classes/structure.php @@ -395,6 +395,7 @@ class mod_attendance_structure { $sess->lasttaken = 0; $sess->lasttakenby = 0; $sess->studentscanmark = 0; + $sess->studentpassword = ''; $event->add_record_snapshot('attendance_sessions', $sess); $event->trigger(); diff --git a/sessions.php b/sessions.php index e527c59..40b9e9e 100644 --- a/sessions.php +++ b/sessions.php @@ -294,11 +294,11 @@ function construct_sessions_data_for_add($formdata) { $sess->description = $formdata->sdescription['text']; $sess->descriptionformat = $formdata->sdescription['format']; $sess->timemodified = $now; - if (isset($formdata->studentscanmark)) { // Students will be able to mark their own attendance. + $sess->studentscanmark = 0; + $sess->studentpassword = ''; + if (isset($formdata->studentscanmark) && !empty($formdata->studentscanmark)) { // Students will be able to mark their own attendance. $sess->studentscanmark = 1; $sess->studentpassword = $formdata->studentpassword; - } else { - $sess->studentpassword = ''; } $sess->statusset = $formdata->statusset;