Esempio n. 1
0
 /**
  * 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 loglive report viewed.
     $event = \report_loglive\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_loglive\\event\\report_viewed', $event);
     $this->assertEquals($context, $event->get_context());
     $expected = array($course->id, 'course', 'report live', "report/loglive/index.php?id={$course->id}", $course->id);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
     $url = new moodle_url('/report/loglive/index.php', array('id' => $course->id));
     $this->assertEquals($url, $event->get_url());
 }
Esempio n. 2
0
$url = new moodle_url("/report/loglive/index.php", $params);
$PAGE->set_url($url);
$PAGE->set_pagelayout('report');
$renderable = new report_loglive_renderable($logreader, $id, $url, 0, $page);
$refresh = $renderable->get_refresh_rate();
$logreader = $renderable->selectedlogreader;
// Include and trigger ajax requests.
if ($page == 0 && !empty($logreader)) {
    // Tell Js to fetch new logs only, by passing time().
    $jsparams = array('since' => time(), 'courseid' => $id, 'page' => $page, 'logreader' => $logreader, 'interval' => $refresh, 'perpage' => $renderable->perpage);
    $PAGE->requires->strings_for_js(array('pause', 'resume'), 'report_loglive');
    $PAGE->requires->yui_module('moodle-report_loglive-fetchlogs', 'Y.M.report_loglive.FetchLogs.init', array($jsparams));
}
$strlivelogs = get_string('livelogs', 'report_loglive');
$strupdatesevery = get_string('updatesevery', 'moodle', $refresh);
if (empty($id)) {
    admin_externalpage_setup('reportloglive', '', null, '', array('pagelayout' => 'report'));
}
$PAGE->set_url($url);
$PAGE->set_context($context);
$PAGE->set_title("{$coursename}: {$strlivelogs} ({$strupdatesevery})");
$PAGE->set_heading("{$coursename}: {$strlivelogs} ({$strupdatesevery})");
$output = $PAGE->get_renderer('report_loglive');
echo $output->header();
echo $output->reader_selector($renderable);
echo $output->toggle_liveupdate_button($renderable);
echo $output->render($renderable);
// Trigger a logs viewed event.
$event = \report_loglive\event\report_viewed::create(array('context' => $context));
$event->trigger();
echo $output->footer();