Пример #1
0
 /**
  * Test the notes viewed event.
  *
  * It's not possible to use the moodle API to simulate the viewing of notes, so here we
  * simply create the event and trigger it.
  */
 public function test_notes_viewed()
 {
     $coursecontext = context_course::instance($this->eventnote->courseid);
     // Trigger event for notes viewed.
     $event = \core\event\notes_viewed::create(array('context' => $coursecontext, 'relateduserid' => $this->eventnote->userid));
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $events = $sink->get_events();
     $event = reset($events);
     $this->assertInstanceOf('\\core\\event\\notes_viewed', $event);
     $this->assertEquals($coursecontext, $event->get_context());
     $expected = array($this->eventnote->courseid, 'notes', 'view', 'index.php?course=' . $this->eventnote->courseid . '&user='******'view notes');
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
 }
Пример #2
0
/**
 * Trigger notes viewed event
 *
 * @param  stdClass $context context object
 * @param  int $userid  user id (the user we are viewing the notes)
 * @since Moodle 2.9
 */
function note_view($context, $userid)
{
    $event = \core\event\notes_viewed::create(array('relateduserid' => $userid, 'context' => $context));
    $event->trigger();
}
Пример #3
0
    }
} else {
    $filtertype = 'course';
    $filterselect = $course->id;
}
require_login($course);
// Output HTML.
if ($course->id == SITEID) {
    $coursecontext = context_system::instance();
} else {
    $coursecontext = context_course::instance($course->id);
}
require_capability('moodle/notes:view', $coursecontext);
$systemcontext = context_system::instance();
// Trigger event.
$event = \core\event\notes_viewed::create(array('relateduserid' => $userid, 'context' => $coursecontext));
$event->trigger();
$strnotes = get_string('notes', 'notes');
if ($userid) {
    $PAGE->set_context(context_user::instance($user->id));
    $PAGE->navigation->extend_for_user($user);
} else {
    $link = null;
    if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) {
        $link = new moodle_url('/user/index.php', array('id' => $course->id));
    }
}
$PAGE->set_pagelayout('course');
$PAGE->set_title($course->shortname . ': ' . $strnotes);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
Пример #4
0
    $filterselect = $course->id;
}
/// require login to access notes
require_login($course);
/// output HTML
if ($course->id == SITEID) {
    $coursecontext = context_system::instance();
    // SYSTEM context
} else {
    $coursecontext = context_course::instance($course->id);
    // Course context
}
$systemcontext = context_system::instance();
// SYSTEM context
// Trigger event.
$event = \core\event\notes_viewed::create(array('courseid' => $courseid, 'relateduserid' => $userid, 'context' => $coursecontext, 'other' => array('content' => 'notes')));
$event->trigger();
if (empty($CFG->enablenotes)) {
    print_error('notesdisabled', 'notes');
}
$strnotes = get_string('notes', 'notes');
if ($userid) {
    $PAGE->set_context(context_user::instance($user->id));
    $PAGE->navigation->extend_for_user($user);
} else {
    $link = null;
    if (has_capability('moodle/course:viewparticipants', $coursecontext) || has_capability('moodle/site:viewparticipants', $systemcontext)) {
        $link = new moodle_url('/user/index.php', array('id' => $course->id));
    }
}
$PAGE->set_pagelayout('course');