Browse Source

Show remarks as hover-icons, instead of single column at the end

MOODLE_28_STABLE
Davo Smith 10 years ago
parent
commit
adeb7c073d
  1. 10
      export.php
  2. 15
      renderer.php
  3. 17
      renderhelpers.php
  4. 21
      styles.css

10
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;

15
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);
}

17
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) {

21
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;
}

Loading…
Cancel
Save