set default values a bit better.
authorDan Marsden <dan@danmarsden.com>
Fri, 28 Apr 2017 03:28:42 +0000 (15:28 +1200)
committerDan Marsden <dan@danmarsden.com>
Fri, 28 Apr 2017 03:30:03 +0000 (15:30 +1200)
classes/structure.php
sessions.php

index 8064f50..3506217 100644 (file)
@@ -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();
index e527c59..40b9e9e 100644 (file)
@@ -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;