Exemplo n.º 1
0
 public function test_collection_read_only()
 {
     $options = array('colltype' => 'instructor', 'course' => $this->course->id);
     $record = $this->getDataGenerator()->create_module('mediagallery', $options);
     // Test instructor can write to an instructor collection and students can't.
     $collection = new \mod_mediagallery\collection($record);
     self::setUser($this->teachers[0]);
     $this->assertFalse($collection->is_read_only());
     self::setUser($this->students[0]);
     $this->assertTrue($collection->is_read_only());
     // Students can write when its not an instructor collection.
     $options = array('colltype' => 'contributed', 'course' => $this->course->id);
     $record = $this->getDataGenerator()->create_module('mediagallery', $options);
     $contributed = new \mod_mediagallery\collection($record);
     $this->assertFalse($contributed->is_read_only());
 }
Exemplo n.º 2
0
if (!$gallery) {
    $mediagallery->sync($forcesync);
}
if ($mediagallery->was_deleted()) {
    $coursecontext = $context->get_course_context();
    $pageurl = new moodle_url('/mod/mediagallery/view.php');
    $PAGE->set_context($coursecontext);
    $PAGE->set_pagelayout('incourse');
    $PAGE->set_url($pageurl);
    echo $OUTPUT->header();
    echo $OUTPUT->notification(get_string('collectionwasdeleted', 'mediagallery'));
    echo $OUTPUT->footer();
    exit;
}
$canedit = $gallery && $gallery->user_can_contribute();
if ($mediagallery->is_read_only() || !$canedit) {
    $options['editing'] = false;
}
require_login($course, true, $cm);
if ($gallery) {
    $pageurl = new moodle_url('/mod/mediagallery/view.php', array('g' => $g, 'page' => $page));
    $navnode = $PAGE->navigation->find($cm->id, navigation_node::TYPE_ACTIVITY);
    if (empty($navnode)) {
        $navnode = $PAGE->navbar;
    }
    $navurl = clone $pageurl;
    $node = $navnode->add(format_string($gallery->name), $navurl);
    $node->make_active();
    if ($options['editing']) {
        $pageurl->param('editing', true);
    }