Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit cfcbff95 authored by Francois Gannaz's avatar Francois Gannaz
Browse files

grantTeacherAccess() on first view

parent b092d457
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
/* @var $DB moodle_database */ /* @var $DB \moodle_database */
use mod_labnbook\fetch\user as fetchUser; use mod_labnbook\fetch\user as fetchUser;
use mod_labnbook\local\helper;
require(__DIR__ . '/../../config.php'); require(__DIR__ . '/../../config.php');
require_once(__DIR__ . '/lib.php'); require_once(__DIR__ . '/lib.php');
...@@ -33,14 +34,19 @@ if ($id) { ...@@ -33,14 +34,19 @@ if ($id) {
} else { } else {
print_error(get_string('missingidandcmid', mod_labnbook)); print_error(get_string('missingidandcmid', mod_labnbook));
} }
/* @var \mod_labnbook\ar\labnbook $moduleinstance */ /* @var $moduleinstance \mod_labnbook\ar\labnbook */
require_login($course, true, $cm); require_login($course, true, $cm);
\mod_labnbook\local\helper::requireLabnbookAuthentication(); helper::requireLabnbookAuthentication();
$modulecontext = context_module::instance($cm->id); $modulecontext = context_module::instance($cm->id);
$coursecontext = context_course::instance($course->id); $coursecontext = context_course::instance($course->id);
// the teacher has access to all the missions and classes used in this course
$isTeacher = has_capability('moodle/course:manageactivities', $coursecontext)
|| has_capability('mod/labnbook:addinstance', $coursecontext);
helper::grantTeacherAccess($course->id);
/* /*
$event = \mod_labnbook\event\course_module_viewed::create(array( $event = \mod_labnbook\event\course_module_viewed::create(array(
'objectid' => $moduleinstance->id, 'objectid' => $moduleinstance->id,
...@@ -51,10 +57,6 @@ $event->add_record_snapshot(LABNBOOK_TABLE, $moduleinstance); ...@@ -51,10 +57,6 @@ $event->add_record_snapshot(LABNBOOK_TABLE, $moduleinstance);
$event->trigger(); $event->trigger();
*/ */
/*
* @todo call API /v1/mission/grant so that the teacher has access to all the missions and classes used in this course
*/
/* @var $PAGE moodle_page */ /* @var $PAGE moodle_page */
$PAGE->set_url('/mod/labnbook/view.php', ['id' => $cm->id]); $PAGE->set_url('/mod/labnbook/view.php', ['id' => $cm->id]);
$PAGE->set_title(format_string($moduleinstance->name)); $PAGE->set_title(format_string($moduleinstance->name));
...@@ -67,8 +69,6 @@ $templateData = [ ...@@ -67,8 +69,6 @@ $templateData = [
'description' => format_text($moduleinstance->intro, $moduleinstance->introformat, ['context' => $modulecontext]), 'description' => format_text($moduleinstance->intro, $moduleinstance->introformat, ['context' => $modulecontext]),
'redirecturl' => $fetcher->getRedirectUrl(), 'redirecturl' => $fetcher->getRedirectUrl(),
]; ];
$isTeacher = has_capability('moodle/course:manageactivities', $coursecontext)
|| has_capability('mod/labnbook:addinstance', $coursecontext);
if ($isTeacher) { if ($isTeacher) {
// editing teacher view // editing teacher view
$templateName = 'view_teacher'; $templateName = 'view_teacher';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment