/** * Test the report viewed event. * * It's not possible to use the moodle API to simulate the viewing of log report, so here we * simply create the event and trigger it. */ public function test_report_viewed() { $course = $this->getDataGenerator()->create_course(); $context = context_course::instance($course->id); // Trigger event for completion report viewed. $event = \report_completion\event\report_viewed::create(array('context' => $context)); // Trigger and capture the event. $sink = $this->redirectEvents(); $event->trigger(); $events = $sink->get_events(); $event = reset($events); $this->assertInstanceOf('\\report_completion\\event\\report_viewed', $event); $this->assertEquals($context, $event->get_context()); $url = new moodle_url('/report/completion/index.php', array('course' => $course->id)); $this->assertEquals($url, $event->get_url()); $this->assertEventContextNotUsed($event); }
if ($csv) { $row[] = $a->date; } else { print '<td class="completion-progresscell">'; // Display course completion status icon print '<img src="' . $OUTPUT->pix_url('i/completion-auto-' . $completiontype) . '" alt="' . $describe . '" class="icon" title="' . $fulldescribe . '" />'; print '</td>'; } if ($csv) { $export->add_data($row); } else { print '</tr>'; } } if ($csv) { $export->download_file(); } else { echo '</tbody>'; } print '</table>'; print $pagingbar; $csvurl = new moodle_url('/report/completion/index.php', array('course' => $course->id, 'format' => 'csv')); $excelurl = new moodle_url('/report/completion/index.php', array('course' => $course->id, 'format' => 'excelcsv')); print '<ul class="export-actions">'; print '<li><a href="' . $csvurl->out() . '">' . get_string('csvdownload', 'completion') . '</a></li>'; print '<li><a href="' . $excelurl->out() . '">' . get_string('excelcsvdownload', 'completion') . '</a></li>'; print '</ul>'; echo $OUTPUT->footer($course); // Trigger a report viewed event. $event = \report_completion\event\report_viewed::create(array('context' => $context)); $event->trigger();