From 1be185141644ea4c30c7f99ae4f2719effa59f42 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Wed, 26 Sep 2018 13:24:37 +1200 Subject: [PATCH] WIP show currently selected status in form. --- classes/output/mobile.php | 14 ++++++++++++-- templates/mobile_teacher_form.mustache | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/classes/output/mobile.php b/classes/output/mobile.php index 02c45e0..11f9029 100644 --- a/classes/output/mobile.php +++ b/classes/output/mobile.php @@ -365,6 +365,15 @@ class mobile { $data['args'] = ''; // Stores list of userid status args that should be added to form post. $statuses = $att->get_statuses(); + $otherdata = array(); + $existinglog = $DB->get_records('attendance_log', + array('sessionid' => $sessid), '', 'studentid,statusid'); + foreach ($existinglog as $log) { + if (!empty($log->statusid)) { + $otherdata['status'.$log->studentid] = $log->statusid; + } + } + foreach ($statuses as $status) { $data['statuses'][] = array('stid' => $status->id, 'acronym' => $status->acronym, 'description' => $status->description); @@ -374,7 +383,8 @@ class mobile { $users = $att->get_users(0, 0); foreach ($users as $user) { $data['users'][] = array('userid' => $user->id, 'fullname' => $user->fullname); - $data['args'] .= ', status'. $user->id. ': status'. $user->id; + // Generate args to use in submission button here. + $data['args'] .= ', status'. $user->id. ': CONTENT_OTHERDATA.status'. $user->id; } if (!empty($data['messages'])) { @@ -390,7 +400,7 @@ class mobile { ], ], 'javascript' => '', - 'otherdata' => '' + 'otherdata' => $otherdata ]; } diff --git a/templates/mobile_teacher_form.mustache b/templates/mobile_teacher_form.mustache index a3ce11b..6dd12ef 100644 --- a/templates/mobile_teacher_form.mustache +++ b/templates/mobile_teacher_form.mustache @@ -41,6 +41,7 @@ "cmid": "25", "courseid": "4", "sessid": "43" + "args" : ", status4: CONTENT_OTHERDATA.status4" } }} {{=<% %>=}} @@ -64,7 +65,7 @@ - + <%#statuses%>