示例#1
0
}
require_login($course, false, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/choice:readresponses', $context);
if (!($choice = choice_get_choice($cm->instance))) {
    print_error('invalidcoursemodule');
}
$strchoice = get_string("modulename", "choice");
$strchoices = get_string("modulenameplural", "choice");
$strresponses = get_string("responses", "choice");
$eventdata = array();
$eventdata['objectid'] = $choice->id;
$eventdata['context'] = $context;
$eventdata['courseid'] = $course->id;
$eventdata['other']['content'] = 'choicereportcontentviewed';
$event = \mod_choice\event\report_viewed::create($eventdata);
$event->trigger();
if (data_submitted() && $action == 'delete' && has_capability('mod/choice:deleteresponses', $context) && confirm_sesskey()) {
    choice_delete_responses($attemptids, $choice, $cm, $course);
    //delete responses.
    redirect("report.php?id={$cm->id}");
}
if (!$download) {
    $PAGE->navbar->add($strresponses);
    $PAGE->set_title(format_string($choice->name) . ": {$strresponses}");
    $PAGE->set_heading($course->fullname);
    echo $OUTPUT->header();
    echo $OUTPUT->heading($choice->name, 2, null);
    /// Check to see if groups are being used in this choice
    $groupmode = groups_get_activity_groupmode($cm);
    if ($groupmode) {
示例#2
0
 /**
  * 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->choice->id;
     $eventdata['context'] = $this->context;
     $eventdata['courseid'] = $this->course->id;
     $eventdata['other']['content'] = 'choicereportcontentviewed';
     // This is fired in a page view so we can't run this through a function.
     $event = \mod_choice\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_choice\\event\\report_viewed', $event[0]);
     $this->assertEquals($USER->id, $event[0]->userid);
     $this->assertEquals(context_module::instance($this->choice->cmid), $event[0]->get_context());
     $expected = array($this->course->id, "choice", "report", 'report.php?id=' . $this->context->instanceid, $this->choice->id, $this->context->instanceid);
     $this->assertEventLegacyLogData($expected, $event[0]);
     $this->assertEventContextNotUsed($event[0]);
     $sink->close();
 }