Beispiel #1
0
 /**
  * Test course_module_instance_list_viewed event.
  */
 public function test_course_module_instance_list_viewed()
 {
     // There is no proper API to call to trigger this event, so what we are
     // doing here is simply making sure that the events returns the right information.
     $course = $this->getDataGenerator()->create_course();
     $params = array('context' => context_course::instance($course->id));
     $event = \mod_resource\event\course_module_instance_list_viewed::create($params);
     // Triggering and capturing the event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $events = $sink->get_events();
     $this->assertCount(1, $events);
     $event = reset($events);
     // Checking that the event contains the expected values.
     $this->assertInstanceOf('\\mod_resource\\event\\course_module_instance_list_viewed', $event);
     $this->assertEquals(context_course::instance($course->id), $event->get_context());
     $expected = array($course->id, 'resource', 'view all', 'index.php?id=' . $course->id, '');
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
 }
Beispiel #2
0
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

require('../../config.php');

$id = required_param('id', PARAM_INT); // course id

$course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST);

require_course_login($course, true);
$PAGE->set_pagelayout('incourse');

$params = array(
    'context' => context_course::instance($course->id)
);
$event = \mod_resource\event\course_module_instance_list_viewed::create($params);
$event->trigger();

$strresource     = get_string('modulename', 'resource');
$strresources    = get_string('modulenameplural', 'resource');
$strsectionname  = get_string('sectionname', 'format_'.$course->format);
$strname         = get_string('name');
$strintro        = get_string('moduleintro');
$strlastmodified = get_string('lastmodified');

$PAGE->set_url('/mod/resource/index.php', array('id' => $course->id));
$PAGE->set_title($course->shortname.': '.$strresources);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strresources);
echo $OUTPUT->header();
echo $OUTPUT->heading($strresources);