Browse Source

Fix #425 new setting to control which sessions appear in the mobile app.

nwp90-nwp90-allsessionsreport
Dan Marsden 5 years ago
parent
commit
7ea69132f7
  1. 10
      classes/output/mobile.php
  2. 6
      lang/en/attendance.php
  3. 12
      settings.php

10
classes/output/mobile.php

@ -70,6 +70,7 @@ class mobile {
$attendance = $DB->get_record('attendance', array('id' => $cm->instance), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$config = get_config('attendance');
$data = array(); // Data to pass to renderer.
$data['cmid'] = $cmid;
@ -126,14 +127,15 @@ class mobile {
}
}
// Get list of sessions within the next 24hrs and in last 6hrs.
// TODO: provide way of adjusting which sessions to show in app.
$time = time() - (6 * 60 * 60);
// Get list of sessions based on site level settings. default = the next 24hrs and in last 6hrs.
$timefrom = time() - $config->mobilesessionfrom;
$timeto = time() + $config->mobilesessionto;
$data['sessions'] = array();
$sessions = $DB->get_records_select('attendance_sessions',
'attendanceid = ? AND sessdate > ? ORDER BY sessdate', array($attendance->id, $time));
'attendanceid = ? AND sessdate > ? AND sessdate < ? ORDER BY sessdate',
array($attendance->id, $timefrom, $timeto));
if (!empty($sessions)) {
$userdata = new \attendance_user_data($att, $USER->id, true);

6
lang/en/attendance.php

@ -275,6 +275,12 @@ $string['maxpossiblepoints'] = 'Maximum possible points';
$string['maxwarn'] = 'Maximum number of e-mail warnings';
$string['maxwarn_help'] = 'The maximum number of times a warning should be sent (only one warning per session is sent)';
$string['mergeuser'] = 'Merge user';
$string['mobilesessionfrom'] = 'Show sessions older than the last';
$string['mobilesessionfrom_help'] = 'Allows the list of sessions to be restricted when marking in the app - only shows sessions that started since this value';
$string['mobilesessionto'] = 'Show future sessions';
$string['mobilesessionto_help'] = 'Allows the list of sessions to be restricted to only show a small number of future sessions.';
$string['mobilesettings'] = 'Mobile app settings';
$string['mobilesettings_help'] = 'These settings control Moodle mobile app behaviour';
$string['modulename'] = 'Attendance';
$string['modulename_help'] = 'The attendance activity module enables a teacher to take attendance during class and students to view their own attendance record.

12
settings.php

@ -105,6 +105,18 @@ if ($ADMIN->fulltree) {
get_string('enablewarnings', 'attendance'),
get_string('enablewarnings_desc', 'attendance'), 0));
$name = new lang_string('mobilesettings', 'mod_attendance');
$description = new lang_string('mobilesettings_help', 'mod_attendance');
$settings->add(new admin_setting_heading('mobilesettings', $name, $description));
$settings->add(new admin_setting_configduration('attendance/mobilesessionfrom',
get_string('mobilesessionfrom', 'attendance'), get_string('mobilesessionfrom_help', 'attendance'),
6 * HOURSECS, PARAM_RAW));
$settings->add(new admin_setting_configduration('attendance/mobilesessionto',
get_string('mobilesessionto', 'attendance'), get_string('mobilesessionto_help', 'attendance'),
24 * HOURSECS, PARAM_RAW));
$name = new lang_string('defaultsettings', 'mod_attendance');
$description = new lang_string('defaultsettings_help', 'mod_attendance');
$settings->add(new admin_setting_heading('defaultsettings', $name, $description));

Loading…
Cancel
Save