From 253fd5f5045ba8ab2bf5170f4860c4c756fbcdda Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Tue, 23 Oct 2018 15:18:31 +1300 Subject: [PATCH] Hack a way to provide a selectall function on teacher marking. Fixes #341 This really should be adjusted to implement a new JS function. --- classes/output/mobile.php | 13 ++++++++++--- db/mobile.php | 3 ++- templates/mobile_teacher_form.mustache | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/classes/output/mobile.php b/classes/output/mobile.php index 2ac6d2e..e0dbe6e 100644 --- a/classes/output/mobile.php +++ b/classes/output/mobile.php @@ -410,9 +410,9 @@ class mobile { foreach ($statuses as $status) { $data['statuses'][] = array('stid' => $status->id, 'acronym' => $status->acronym, - 'description' => $status->description); + 'description' => $status->description, 'selectall' => ''); } - // TODO: Add support for group marking (non-editing teachers etc). + $data['users'] = array(); $users = $att->get_users($att->get_session_info($sessid)->groupid, 0); foreach ($users as $user) { @@ -422,8 +422,15 @@ class mobile { $data['users'][] = array('userid' => $user->id, 'fullname' => $user->fullname, 'profileimageurl' => $profileimageurl); // Generate args to use in submission button here. $data['btnargs'] .= ', status'. $user->id. ': CONTENT_OTHERDATA.status'. $user->id; + // Really Hacky way to do a select-all. This really needs to be moved into a JS function within the app. + foreach ($statuses as $status) { + foreach ($data['statuses'] as $id => $st) { // Statuses not ordered by statusid. + if ($st['stid'] == $status->id) { // Find the item that we need to add to. + $data['statuses'][$id]['selectall'] .= "CONTENT_OTHERDATA.status".$user->id."=".$status->id.";"; + } + } + } } - if (!empty($data['messages'])) { $data['showmessage'] = true; } diff --git a/db/mobile.php b/db/mobile.php index afac2dd..720e920 100644 --- a/db/mobile.php +++ b/db/mobile.php @@ -63,7 +63,8 @@ $addons = [ ['subnetwrong', 'attendance'], ['enterpassword', 'attendance'], ['incorrectpasswordshort', 'attendance'], - ['attendancesuccess', 'attendance'] + ['attendancesuccess', 'attendance'], + ['setallstatuses', 'attendance'] ], ] ]; \ No newline at end of file diff --git a/templates/mobile_teacher_form.mustache b/templates/mobile_teacher_form.mustache index 635c58f..bd1d8bb 100644 --- a/templates/mobile_teacher_form.mustache +++ b/templates/mobile_teacher_form.mustache @@ -58,6 +58,22 @@ <%/messages%> <%/showmessage%> + + + {{ 'plugin.mod_attendance.setallstatuses' | translate }} + + + <%#statuses%> + + + + <% acronym %> + + + + <%/statuses%> + + <%#users%>