From adeb7c073de9deae1bcec237efbd67f6c7cc51f6 Mon Sep 17 00:00:00 2001 From: Davo Smith Date: Thu, 25 Jun 2015 12:02:19 +0100 Subject: [PATCH] Show remarks as hover-icons, instead of single column at the end --- export.php | 10 ++++++++-- renderer.php | 15 +-------------- renderhelpers.php | 17 +++++++++++++++-- styles.css | 21 +++++++++++++++++++++ 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/export.php b/export.php index d6a5253..534cadb 100644 --- a/export.php +++ b/export.php @@ -112,7 +112,7 @@ if ($formdata = $mform->get_data()) { $text .= $sess->groupid ? $reportdata->groups[$sess->groupid]->name : get_string('commonsession', 'attendance'); $data->tabhead[] = $text; if (isset($formdata->includeremarks)) { - $data->tabhead[] = get_string('remark', 'attendance', $text); + $data->tabhead[] = ''; // Space for the remarks. } } } else { @@ -216,7 +216,13 @@ function exporttotableed($data, $filename, $format) { $i = 3; $j = 0; foreach ($data->tabhead as $cell) { - $myxls->write($i, $j++, $cell, $formatbc); + // Merge cells if the heading would be empty (remarks column). + if (empty($cell)) { + $myxls->merge_cells($i, $j - 1, $i, $j); + } else { + $myxls->write($i, $j, $cell, $formatbc); + } + $j++; } $i++; $j = 0; diff --git a/renderer.php b/renderer.php index 753c560..3aea268 100644 --- a/renderer.php +++ b/renderer.php @@ -846,11 +846,6 @@ class mod_attendance_renderer extends plugin_renderer_base { $table->size[] = '1px'; } - if ($reportdata->sessionslog) { - $table->head[] = get_string('remarks', 'attendance'); - $table->align[] = 'center'; - $table->size[] = '200px'; - } if ($bulkmessagecapability) { // Display the table header for bulk messaging. // The checkbox must have an id of cb_selector so that the JavaScript will pick it up. @@ -865,7 +860,7 @@ class mod_attendance_renderer extends plugin_renderer_base { $row->cells[] = $this->user_picture($user); // Show different picture if it is a temporary user. $row->cells[] = html_writer::link($reportdata->url_view(array('studentid' => $user->id)), fullname($user)); $cellsgenerator = new user_sessions_cells_html_generator($reportdata, $user); - $row->cells = array_merge($row->cells, $cellsgenerator->get_cells()); + $row->cells = array_merge($row->cells, $cellsgenerator->get_cells(true)); foreach ($reportdata->statuses as $status) { if (array_key_exists($status->id, $reportdata->usersstats[$user->id])) { @@ -880,14 +875,6 @@ class mod_attendance_renderer extends plugin_renderer_base { $row->cells[] = format_float($reportdata->grades[$user->id]).' / '.format_float($reportdata->maxgrades[$user->id]); } - if ($reportdata->sessionslog) { - if (isset($sess) && isset($reportdata->sessionslog[$user->id][$sess->id]->remarks)) { - $row->cells[] = $reportdata->sessionslog[$user->id][$sess->id]->remarks; - } else { - $row->cells[] = ''; - } - } - if ($bulkmessagecapability) { // Create the checkbox for bulk messaging. $row->cells[] = html_writer::checkbox('user'.$user->id, 'on', false); } diff --git a/renderhelpers.php b/renderhelpers.php index f190c7f..b8d12fb 100644 --- a/renderhelpers.php +++ b/renderhelpers.php @@ -162,8 +162,21 @@ class user_sessions_cells_html_generator extends user_sessions_cells_generator { } protected function construct_remarks_cell($text) { - $this->close_open_cell_if_needed(); - $this->cells[] = $text; + global $OUTPUT; + + if (!trim($text)) { + return; + } + + // Format the remark. + $icon = $OUTPUT->pix_icon('i/info', ''); + $remark = html_writer::span($text, 'remarkcontent'); + $remark = html_writer::span($icon.$remark, 'remarkholder'); + + // Add it into the previous cell. + $markcell = array_pop($this->cells); + $markcell .= ' '.$remark; + $this->cells[] = $markcell; } protected function construct_not_existing_for_user_session_cell($text) { diff --git a/styles.css b/styles.css index c08ce76..a57c33d 100644 --- a/styles.css +++ b/styles.css @@ -131,3 +131,24 @@ text-align: right; } +.path-mod-attendance .remarkholder { + position: relative; +} + +.path-mod-attendance .remarkholder .remarkcontent { + display: none; + position: absolute; + border: 1px solid #ccc; + border-radius: 3px; + box-shadow: 3px 3px 5px #ccc; + background-color: white; + left: 20px; + top: 0; + padding: 5px; + width: 150px; + z-index: 5000; +} + +.path-mod-attendance .remarkholder:hover .remarkcontent { + display: inline-block; +}