Esempio n. 1
0
 /**
  * Test report viewed event.
  */
 public function test_report_viewed()
 {
     // There is no proper API to call to generate chapters for a book, so what we are
     // doing here is simply making sure that the events returns the right information.
     $course = $this->getDataGenerator()->create_course();
     $survey = $this->getDataGenerator()->create_module('survey', array('course' => $course->id));
     $params = array('objectid' => $survey->id, 'context' => context_module::instance($survey->cmid), 'courseid' => $course->id);
     $event = \mod_survey\event\report_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_survey\\event\\report_viewed', $event);
     $this->assertEquals(context_module::instance($survey->cmid), $event->get_context());
     $this->assertEquals($survey->id, $event->objectid);
     $expected = array($course->id, "survey", "view report", 'report.php?id=' . $survey->cmid, $survey->id, $survey->cmid);
     $this->assertEventLegacyLogData($expected, $event);
     $this->assertEventContextNotUsed($event);
 }
Esempio n. 2
0
}
$PAGE->set_title("{$course->shortname}: " . format_string($survey->name));
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->heading($survey->name);
/// Check to see if groups are being used in this survey
if ($groupmode = groups_get_activity_groupmode($cm)) {
    // Groups are being used
    $menuaction = $action == "student" ? "students" : $action;
    $currentgroup = groups_get_activity_group($cm, true);
    groups_print_activity_menu($cm, $CFG->wwwroot . "/mod/survey/report.php?id={$cm->id}&action={$menuaction}&qid={$qid}");
} else {
    $currentgroup = 0;
}
$params = array('objectid' => $survey->id, 'context' => $context, 'courseid' => $course->id, 'relateduserid' => $student, 'other' => array('action' => $action, 'groupid' => $currentgroup));
$event = \mod_survey\event\report_viewed::create($params);
$event->trigger();
if ($currentgroup) {
    $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $currentgroup, null, false);
} else {
    if (!empty($cm->groupingid)) {
        $groups = groups_get_all_groups($courseid, 0, $cm->groupingid);
        $groups = array_keys($groups);
        $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', $groups, null, false);
    } else {
        $users = get_users_by_capability($context, 'mod/survey:participate', '', '', '', '', '', null, false);
        $group = false;
    }
}
$groupingid = $cm->groupingid;
echo $OUTPUT->box_start("generalbox boxaligncenter");