コード例 #1
0
ファイル: logging_test.php プロジェクト: gabrielrosset/moodle
 /**
  * Test course_module_instance_list_viewed event.
  */
 public function test_logging()
 {
     // 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 = \gradeexport_ods\event\grade_exported::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('\\gradeexport_ods\\event\\grade_exported', $event);
     $this->assertEquals(context_course::instance($course->id), $event->get_context());
     $this->assertEquals('ods', $event->get_export_type());
 }
コード例 #2
0
ファイル: export.php プロジェクト: evltuma/moodle
    print_error('nocourseid');
}
require_login($course);
$context = context_course::instance($id);
$groupid = groups_get_course_group($course, true);
require_capability('moodle/grade:export', $context);
require_capability('gradeexport/ods:view', $context);
// We need to call this method here before any output otherwise the menu won't display.
// If you use this method without this check, will break the direct grade exporting (without publishing).
$key = optional_param('key', '', PARAM_RAW);
if (!empty($CFG->gradepublishing) && !empty($key)) {
    print_grade_page_head($COURSE->id, 'export', 'ods', get_string('exportto', 'grades') . ' ' . get_string('pluginname', 'gradeexport_ods'));
}
if (groups_get_course_groupmode($COURSE) == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $context)) {
    if (!groups_is_member($groupid, $USER->id)) {
        print_error('cannotaccessgroup', 'grades');
    }
}
$mform = new grade_export_form(null, array('publishing' => true, 'simpleui' => true, 'multipledisplaytypes' => true));
$data = $mform->get_data();
$export = new grade_export_ods($course, $groupid, $data);
// If the gradepublishing is enabled and user key is selected print the grade publishing link.
if (!empty($CFG->gradepublishing) && !empty($key)) {
    groups_print_course_menu($course, 'index.php?id=' . $id);
    echo $export->get_grade_publishing_url();
    echo $OUTPUT->footer();
} else {
    $event = \gradeexport_ods\event\grade_exported::create(array('context' => $context));
    $event->trigger();
    $export->print_grades();
}