/** * Test the report viewed event. */ public function test_report_viewed() { $requestedqtype = 'all'; $event = \report_questioninstances\event\report_viewed::create(array('other' => array('requestedqtype' => $requestedqtype))); // Trigger and capture the event. $sink = $this->redirectEvents(); $event->trigger(); $events = $sink->get_events(); $event = reset($events); $this->assertInstanceOf('\\report_questioninstances\\event\\report_viewed', $event); $this->assertEquals(context_system::instance(), $event->get_context()); $expected = array(SITEID, "admin", "report questioninstances", "report/questioninstances/index.php?qtype={$requestedqtype}", $requestedqtype); $this->assertEventLegacyLogData($expected, $event); $this->assertEventContextNotUsed($event); $url = new moodle_url('/report/questioninstances/index.php', array('qtype' => $requestedqtype)); $this->assertEquals($url, $event->get_url()); $event->get_name(); }
* * @package report * @subpackage questioninstances * @copyright 2008 Tim Hunt * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require dirname(__FILE__) . '/../../config.php'; require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->libdir . '/questionlib.php'; // Get URL parameters. $requestedqtype = optional_param('qtype', '', PARAM_SAFEDIR); // Print the header & check permissions. admin_externalpage_setup('reportquestioninstances', '', null, '', array('pagelayout' => 'report')); echo $OUTPUT->header(); // Log. \report_questioninstances\event\report_viewed::create(array('other' => array('requestedqtype' => $requestedqtype)))->trigger(); // Prepare the list of capabilities to choose from $qtypes = question_bank::get_all_qtypes(); $qtypechoices = array(); foreach ($qtypes as $qtype) { $qtypechoices[$qtype->name()] = $qtype->local_name(); } // Print the settings form. echo $OUTPUT->box_start('generalbox boxwidthwide boxaligncenter centerpara'); echo '<form method="get" action="." id="settingsform"><div>'; echo $OUTPUT->heading(get_string('reportsettings', 'report_questioninstances')); echo '<p id="intro">', get_string('intro', 'report_questioninstances'), '</p>'; echo '<p><label for="menuqtype"> ' . get_string('questiontype', 'admin') . '</label> '; echo html_writer::select($qtypechoices, 'qtype', $requestedqtype, array('_all_' => get_string('all'))); echo '</p>'; echo '<p><input type="submit" id="settingssubmit" value="' . get_string('getreport', 'report_questioninstances') . '" /></p>';