Browse Source

WIP Take teacher attendance.

MOODLE_36_STABLE
Dan Marsden 6 years ago
parent
commit
b9f328fabd
  1. 15
      classes/output/mobile.php
  2. 3
      db/mobile.php
  3. 2
      templates/mobile_teacher_form.mustache

15
classes/output/mobile.php

@ -75,7 +75,10 @@ class mobile {
// Add stats for this use to output. // Add stats for this use to output.
$pageparams = new \mod_attendance_view_page_params(); $pageparams = new \mod_attendance_view_page_params();
$pageparams->studentid = $USER->id; $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->sessionid = $sessid;
} }
$pageparams->mode = \mod_attendance_view_page_params::MODE_THIS_COURSE; $pageparams->mode = \mod_attendance_view_page_params::MODE_THIS_COURSE;
@ -88,14 +91,16 @@ class mobile {
$userkeys = preg_grep("/status\d+/", $keys); $userkeys = preg_grep("/status\d+/", $keys);
if (!empty($userkeys)) { // If this is a post from the teacher form. if (!empty($userkeys)) { // If this is a post from the teacher form.
// Build data to pass to take_from_form_data. // Build data to pass to take_from_form_data.
$formdata = new \stdClass();
foreach ($userkeys as $uk) { foreach ($userkeys as $uk) {
$userid = str_replace('status', '', $uk); $userid = str_replace('status', '', $uk);
$status = $args[$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';
} }
} }

3
db/mobile.php

@ -62,7 +62,8 @@ $addons = [
['closed', 'attendance'], ['closed', 'attendance'],
['subnetwrong', 'attendance'], ['subnetwrong', 'attendance'],
['enterpassword', 'attendance'], ['enterpassword', 'attendance'],
['incorrectpasswordshort', 'attendance'] ['incorrectpasswordshort', 'attendance'],
['attendancesuccess', 'attendance']
], ],
] ]
]; ];

2
templates/mobile_teacher_form.mustache

@ -67,7 +67,7 @@
<%/statuses%> <%/statuses%>
</ion-list> </ion-list>
<%/users%> <%/users%>
<button ion-button core-site-plugins-new-content component="mod_attendance" method="mobile_view_activity" [args]="{cmid: <% cmid %>, courseid: <% courseid %>, sessid: <% sessid %> <% args %>}"> <button ion-button core-site-plugins-new-content component="mod_attendance" method="mobile_view_activity" [args]="{cmid: <% cmid %>, courseid: <% courseid %>, sessid: <% sessid %><% args %>}">
{{ 'plugin.mod_attendance.submitattendance' | translate }} {{ 'plugin.mod_attendance.submitattendance' | translate }}
</button> </button>

Loading…
Cancel
Save