コード例 #1
0
ファイル: events_test.php プロジェクト: Gavinthisisit/Moodle
 /**
  * Test to ensure that event data is being stored correctly.
  */
 public function test_report_viewed()
 {
     global $USER;
     $this->resetAfterTest();
     // Generate user data.
     $this->setAdminUser();
     $eventdata = array();
     $eventdata['objectid'] = $this->randchoice->id;
     $eventdata['context'] = $this->context;
     $eventdata['courseid'] = $this->course->id;
     $eventdata['other']['content'] = 'randchoicereportcontentviewed';
     // This is fired in a page view so we can't run this through a function.
     $event = \mod_randchoice\event\report_viewed::create($eventdata);
     // Redirect event.
     $sink = $this->redirectEvents();
     $event->trigger();
     $event = $sink->get_events();
     // Data checking.
     $this->assertCount(1, $event);
     $this->assertInstanceOf('\\mod_randchoice\\event\\report_viewed', $event[0]);
     $this->assertEquals($USER->id, $event[0]->userid);
     $this->assertEquals(context_module::instance($this->randchoice->cmid), $event[0]->get_context());
     $expected = array($this->course->id, "randchoice", "report", 'report.php?id=' . $this->context->instanceid, $this->randchoice->id, $this->context->instanceid);
     $this->assertEventLegacyLogData($expected, $event[0]);
     $this->assertEventContextNotUsed($event[0]);
     $sink->close();
 }
コード例 #2
0
ファイル: report.php プロジェクト: Gavinthisisit/Moodle
}
require_login($course, false, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/randchoice:readresponses', $context);
if (!($randchoice = randchoice_get_randchoice($cm->instance))) {
    print_error('invalidcoursemodule');
}
$strrandchoice = get_string("modulename", "randchoice");
$strrandchoices = get_string("modulenameplural", "randchoice");
$strresponses = get_string("responses", "randchoice");
$eventdata = array();
$eventdata['objectid'] = $randchoice->id;
$eventdata['context'] = $context;
$eventdata['courseid'] = $course->id;
$eventdata['other']['content'] = 'randchoicereportcontentviewed';
$event = \mod_randchoice\event\report_viewed::create($eventdata);
$event->trigger();
if (data_submitted() && $action == 'delete' && has_capability('mod/randchoice:deleteresponses', $context) && confirm_sesskey()) {
    randchoice_delete_responses($attemptids, $randchoice, $cm, $course);
    //delete responses.
    redirect("report.php?id={$cm->id}");
}
if (!$download) {
    $PAGE->navbar->add($strresponses);
    $PAGE->set_title(format_string($randchoice->name) . ": {$strresponses}");
    $PAGE->set_heading($course->fullname);
    echo $OUTPUT->header();
    echo $OUTPUT->heading($randchoice->name, 2, null);
    /// Check to see if groups are being used in this randchoice
    $groupmode = groups_get_activity_groupmode($cm);
    if ($groupmode) {