Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LabNbook
LabNbook-Moodle
Commits
cfcbff95
Commit
cfcbff95
authored
Jan 21, 2020
by
Francois Gannaz
Browse files
grantTeacherAccess() on first view
parent
b092d457
Changes
1
Hide whitespace changes
Inline
Side-by-side
view.php
View file @
cfcbff95
...
...
@@ -7,9 +7,10 @@
* @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
\
local\helper
;
require
(
__DIR__
.
'/../../config.php'
);
require_once
(
__DIR__
.
'/lib.php'
);
...
...
@@ -33,14 +34,19 @@ if ($id) {
}
else
{
print_error
(
get_string
(
'missingidandcmid'
,
mod_labnbook
));
}
/* @var \mod_labnbook\ar\labnbook
$moduleinstance
*/
/* @var
$moduleinstance
\mod_labnbook\ar\labnbook */
require_login
(
$course
,
true
,
$cm
);
\
mod_labnbook\local\
helper
::
requireLabnbookAuthentication
();
helper
::
requireLabnbookAuthentication
();
$modulecontext
=
context_module
::
instance
(
$cm
->
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(
'objectid' => $moduleinstance->id,
...
...
@@ -51,10 +57,6 @@ $event->add_record_snapshot(LABNBOOK_TABLE, $moduleinstance);
$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 */
$PAGE
->
set_url
(
'/mod/labnbook/view.php'
,
[
'id'
=>
$cm
->
id
]);
$PAGE
->
set_title
(
format_string
(
$moduleinstance
->
name
));
...
...
@@ -67,8 +69,6 @@ $templateData = [
'description'
=>
format_text
(
$moduleinstance
->
intro
,
$moduleinstance
->
introformat
,
[
'context'
=>
$modulecontext
]),
'redirecturl'
=>
$fetcher
->
getRedirectUrl
(),
];
$isTeacher
=
has_capability
(
'moodle/course:manageactivities'
,
$coursecontext
)
||
has_capability
(
'mod/labnbook:addinstance'
,
$coursecontext
);
if
(
$isTeacher
)
{
// editing teacher view
$templateName
=
'view_teacher'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment