Add ability to exlude sessions from absentee report calculations.
authorDan Marsden <dan@danmarsden.com>
Wed, 6 Dec 2017 19:57:18 +0000 (08:57 +1300)
committerDan Marsden <dan@danmarsden.com>
Wed, 6 Dec 2017 19:57:18 +0000 (08:57 +1300)
add_form.php
db/install.xml
db/upgrade.php
lang/en/attendance.php
locallib.php
settings.php
version.php

index cda63d3..23acf85 100644 (file)
@@ -125,6 +125,17 @@ class mod_attendance_add_form extends moodleform {
                             array('maxfiles' => EDITOR_UNLIMITED_FILES, 'noclean' => true, 'context' => $modcontext));
         $mform->setType('sdescription', PARAM_RAW);
 
+        // If warnings allow selector for reporting.
+        if (!empty(get_config('attendance', 'enablewarnings'))) {
+            $mform->addElement('checkbox', 'absenteereport', '', get_string('includeabsentee', 'attendance'));
+            $mform->addHelpButton('absenteereport', 'includeabsentee', 'attendance');
+            if (isset($pluginconfig->absenteereport_default)) {
+                $mform->setDefault('absenteereport', $pluginconfig->absenteereport_default);
+            }
+        } else {
+            $mform->addElement('hidden', 'absenteereport', 1);
+            $mform->setType('absenteereport', PARAM_INT);
+        }
         // For multiple sessions.
         $mform->addElement('header', 'headeraddmultiplesessions', get_string('addmultiplesessions', 'attendance'));
         if (!empty($pluginconfig->multisessionexpanded)) {
index efd9c6c..910eef3 100644 (file)
@@ -24,7 +24,7 @@
         <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
       </INDEXES>
     </TABLE>
-    <TABLE NAME="attendance_sessions" COMMENT="attendance_sessions table retrofitted from MySQL">
+    <TABLE NAME="attendance_sessions" COMMENT="attendance_sessions table">
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
         <FIELD NAME="attendanceid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
@@ -42,6 +42,7 @@
         <FIELD NAME="automark" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
         <FIELD NAME="automarkcompleted" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
         <FIELD NAME="statusset" TYPE="int" LENGTH="5" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Which set of statuses to use"/>
+        <FIELD NAME="absenteereport" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
         <FIELD NAME="caleventid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
       </FIELDS>
       <KEYS>
index ce1be8e..e18fceb 100644 (file)
@@ -453,5 +453,18 @@ function xmldb_attendance_upgrade($oldversion=0) {
         // Attendance savepoint reached.
         upgrade_mod_savepoint(true, 2017082200, 'attendance');
     }
+
+    if ($oldversion < 2017120700) {
+        $table = new xmldb_table('attendance_sessions');
+
+        $field = new xmldb_field('absenteereport');
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'statusset');
+        if (!$dbman->field_exists($table, $field)) {
+            $dbman->add_field($table, $field);
+        }
+
+        upgrade_mod_savepoint(true, 2017120700, 'attendance');
+    }
+
     return $result;
 }
index f7c44b9..98ec2c2 100644 (file)
@@ -498,3 +498,5 @@ $string['warningthreshold'] = 'Warning threshold';
 $string['week'] = 'week(s)';
 $string['weeks'] = 'Weeks';
 $string['youcantdo'] = 'You can\'t do anything';
+$string['includeabsentee'] = 'Include session when calculating absentee report';
+$string['includeabsentee_help'] = 'If checked this session will be included in the absentee report calculations.';
\ No newline at end of file
index 3d40c11..b528463 100644 (file)
@@ -765,7 +765,7 @@ function attendance_get_users_to_notify($courseids = array(), $orderby = '', $al
                          GROUP BY attendanceid, setnumber) stm
                      ON (stm.setnumber = ats.statusset AND stm.attendanceid = ats.attendanceid)
                   {$joingroup}
-                  WHERE 1 = 1 {$where}
+                  WHERE ats.absenteereport = 1 {$where}
                 GROUP BY uniqueid, a.id, a.name, a.course, c.fullname, atl.studentid, n.id, n.warningpercent,
                          n.emailsubject, n.emailcontent, n.emailcontentformat, n.warnafter, n.maxwarn,
                          n.emailuser, n.thirdpartyemails, cm.id, c.id, {$unames2}, ns.userid
index 42c8eb4..a8acb0f 100644 (file)
@@ -101,6 +101,9 @@ if ($ADMIN->fulltree) {
     $description = new lang_string('defaultsessionsettings_help', 'mod_attendance');
     $settings->add(new admin_setting_heading('defaultsessionsettings', $name, $description));
 
+    $settings->add(new admin_setting_configcheckbox('attendance/absenteereport_default',
+        get_string('includeabsentee', 'attendance'), '', 1));
+
     $settings->add(new admin_setting_configcheckbox('attendance/studentscanmark_default',
         get_string('studentscanmark', 'attendance'), '', 0));
 
index e4e12c1..3e9503d 100644 (file)
@@ -23,9 +23,9 @@
  */
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version  = 2017112000;
+$plugin->version  = 2017120700;
 $plugin->requires = 2017102700; // Requires 3.4
-$plugin->release = '3.4.1';
+$plugin->release = '3.4.2';
 $plugin->maturity  = MATURITY_ALPHA;
 $plugin->cron     = 0;
 $plugin->component = 'mod_attendance';