From 5d2676d775bb35dce44aa7977e6dd0d46e8fb553 Mon Sep 17 00:00:00 2001 From: Dan Marsden Date: Thu, 11 May 2017 12:03:04 +1200 Subject: [PATCH] Add abilty to view student password from session list page. --- pix/key.svg | 1 + renderer.php | 20 ++++++++++++++++---- styles.css | 3 +++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 pix/key.svg diff --git a/pix/key.svg b/pix/key.svg new file mode 100644 index 0000000..0d3f3d9 --- /dev/null +++ b/pix/key.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/renderer.php b/renderer.php index f565c5d..05e2163 100644 --- a/renderer.php +++ b/renderer.php @@ -257,8 +257,8 @@ class mod_attendance_renderer extends plugin_renderer_base { get_string('actions'), html_writer::checkbox('cb_selector', 0, false, '', array('id' => 'cb_selector')) ); - $table->align = array('', 'right', '', '', 'left', 'center', 'center'); - $table->size = array('1px', '1px', '1px', '', '*', '110px', '1px'); + $table->align = array('', 'right', '', '', 'left', 'right', 'center'); + $table->size = array('1px', '1px', '1px', '', '*', '120px', '1px'); $i = 0; foreach ($sessdata->sessions as $key => $sess) { @@ -300,6 +300,18 @@ class mod_attendance_renderer extends plugin_renderer_base { */ private function construct_date_time_actions(attendance_manage_data $sessdata, $sess) { $actions = ''; + if (!empty($sess->studentpassword) && + (has_capability('mod/attendance:manageattendances', $sessdata->att->context) || + has_capability('mod/attendance:takeattendances', $sessdata->att->context) || + has_capability('mod/attendance:changeattendances', $sessdata->att->context))) { + + $icon = new pix_icon('key', '', 'attendance'); + $attributes = array("class" => "btn-link p-a-0", "role" => "button", + "data-toggle" => "popover", "data-placement" => "left", "data-html" => "true", + "tabindex" => "0", "data-trigger" => "manual"); + $attributes['data-content'] = html_writer::span($sess->studentpassword, 'student-pass'); + $actions .= html_writer::tag('a', $this->output->render($icon), $attributes); + } $date = userdate($sess->sessdate, get_string('strftimedmyw', 'attendance')); $time = $this->construct_time($sess->sessdate, $sess->duration); @@ -311,7 +323,7 @@ class mod_attendance_renderer extends plugin_renderer_base { $date = html_writer::link($url, $date, array('title' => $title)); $time = html_writer::link($url, $time, array('title' => $title)); - $actions = $this->output->action_icon($url, new pix_icon('redo', $title, 'attendance')); + $actions .= $this->output->action_icon($url, new pix_icon('redo', $title, 'attendance')); } else { $date = '' . $date . ''; $time = '' . $time . ''; @@ -320,7 +332,7 @@ class mod_attendance_renderer extends plugin_renderer_base { if (has_capability('mod/attendance:takeattendances', $sessdata->att->context)) { $url = $sessdata->url_take($sess->id, $sess->groupid); $title = get_string('takeattendance', 'attendance'); - $actions = $this->output->action_icon($url, new pix_icon('t/go', $title)); + $actions .= $this->output->action_icon($url, new pix_icon('t/go', $title)); } } diff --git a/styles.css b/styles.css index 5c4ed93..f79d923 100644 --- a/styles.css +++ b/styles.css @@ -186,3 +186,6 @@ .path-mod-attendance .attreport .narrow { width: 1px; } +.path-mod-attendance .student-pass { + font-size: x-large; +}