From b9f328fabd4c4972c505e478859da4f5a7d7ba60 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 26 Sep 2018 09:54:19 +1200 Subject: [PATCH] WIP Take teacher attendance. --- classes/output/mobile.php | 15 ++++++++++----- db/mobile.php | 3 ++- templates/mobile_teacher_form.mustache | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/classes/output/mobile.php b/classes/output/mobile.php index 4ce1647..02c45e0 100644 --- a/classes/output/mobile.php +++ b/classes/output/mobile.php @@ -75,7 +75,10 @@ class mobile { // Add stats for this use to output. $pageparams = new \mod_attendance_view_page_params(); $pageparams->studentid = $USER->id; - if (!empty($takenstatus) && !empty($sessid)) { + $pageparams->group = groups_get_activity_group($cm, true); + if (!empty($sessid) && (!empty($takenstatus) || $isteacher)) { + $session = $DB->get_record('attendance_sessions', array('id' => $sessid)); + $pageparams->grouptype = $session->groupid; $pageparams->sessionid = $sessid; } $pageparams->mode = \mod_attendance_view_page_params::MODE_THIS_COURSE; @@ -88,14 +91,16 @@ class mobile { $userkeys = preg_grep("/status\d+/", $keys); if (!empty($userkeys)) { // If this is a post from the teacher form. // Build data to pass to take_from_form_data. + $formdata = new \stdClass(); foreach ($userkeys as $uk) { $userid = str_replace('status', '', $uk); $status = $args[$uk]; - + $formdata->{'remarks'.$userid} = ''; + $formdata->{'user'.$userid} = $status; } - // Call take_from_form_data function. - // $att->take_from_form_data($formdata); - + $att->take_from_form_data($formdata); + $data['showmessage'] = true; + $data['messages'][]['string'] = 'attendancesuccess'; } } diff --git a/db/mobile.php b/db/mobile.php index eeb1c09..13f6e39 100644 --- a/db/mobile.php +++ b/db/mobile.php @@ -62,7 +62,8 @@ $addons = [ ['closed', 'attendance'], ['subnetwrong', 'attendance'], ['enterpassword', 'attendance'], - ['incorrectpasswordshort', 'attendance'] + ['incorrectpasswordshort', 'attendance'], + ['attendancesuccess', 'attendance'] ], ] ]; \ No newline at end of file diff --git a/templates/mobile_teacher_form.mustache b/templates/mobile_teacher_form.mustache index 1526364..86b3c44 100644 --- a/templates/mobile_teacher_form.mustache +++ b/templates/mobile_teacher_form.mustache @@ -67,7 +67,7 @@ <%/statuses%> <%/users%> -