diff --git a/add_form.php b/add_form.php index 21b4ea1..791f7c4 100644 --- a/add_form.php +++ b/add_form.php @@ -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)) { diff --git a/db/install.xml b/db/install.xml index efd9c6c..910eef3 100644 --- a/db/install.xml +++ b/db/install.xml @@ -24,7 +24,7 @@ - +
@@ -42,6 +42,7 @@ + diff --git a/db/upgrade.php b/db/upgrade.php index 0b01956..04f0c0c 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -440,5 +440,18 @@ function xmldb_attendance_upgrade($oldversion=0) { // Attendance savepoint reached. upgrade_mod_savepoint(true, 2016121321, 'attendance'); } + + if ($oldversion < 2016121324) { + $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, 2016121324, 'attendance'); + } + return $result; } diff --git a/lang/en/attendance.php b/lang/en/attendance.php index f7c44b9..98ec2c2 100644 --- a/lang/en/attendance.php +++ b/lang/en/attendance.php @@ -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 diff --git a/locallib.php b/locallib.php index 3d40c11..b528463 100644 --- a/locallib.php +++ b/locallib.php @@ -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 diff --git a/settings.php b/settings.php index 42c8eb4..a8acb0f 100644 --- a/settings.php +++ b/settings.php @@ -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)); diff --git a/version.php b/version.php index 4237d06..1d40a0e 100644 --- a/version.php +++ b/version.php @@ -23,9 +23,9 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2016121323; +$plugin->version = 2016121324; $plugin->requires = 2016111800; -$plugin->release = '3.2.17'; +$plugin->release = '3.2.18'; $plugin->maturity = MATURITY_STABLE; $plugin->cron = 0; $plugin->component = 'mod_attendance';