mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'MDL-64528-master' of https://github.com/mackensen/moodle
This commit is contained in:
commit
6ada5b713b
5 changed files with 13 additions and 1 deletions
|
@ -75,6 +75,7 @@ class core_completion_external extends external_api {
|
|||
|
||||
$context = context_module::instance($cmid);
|
||||
self::validate_context($context);
|
||||
require_capability('moodle/course:togglecompletion', $context);
|
||||
|
||||
list($course, $cm) = get_course_and_cm_from_cmid($cmid);
|
||||
|
||||
|
|
|
@ -468,7 +468,7 @@ class core_course_renderer extends plugin_renderer_base {
|
|||
$imgalt = get_string('completion-alt-' . $completionicon, 'completion', $formattedname);
|
||||
}
|
||||
|
||||
if ($this->page->user_is_editing()) {
|
||||
if ($this->page->user_is_editing() || !has_capability('moodle/course:togglecompletion', $mod->context)) {
|
||||
// When editing, the icon is just an image.
|
||||
$completionpixicon = new pix_icon('i/completion-'.$completionicon, $imgalt, '',
|
||||
array('title' => $imgalt, 'class' => 'iconsmall'));
|
||||
|
|
|
@ -139,6 +139,7 @@ $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
|
|||
|
||||
// Check user is logged in
|
||||
require_login($course, false, $cm);
|
||||
require_capability('moodle/course:togglecompletion', context_module::instance($cmid));
|
||||
|
||||
if (isguestuser() or !confirm_sesskey()) {
|
||||
print_error('error');
|
||||
|
|
|
@ -492,3 +492,4 @@ $string['privacy:metadata:role_capabilities:roleid'] = 'The ID of the role';
|
|||
$string['privacy:metadata:role_capabilities:tableexplanation'] = 'The capabilities and override capabilities for a particular role in a particular context';
|
||||
$string['privacy:metadata:role_capabilities:timemodified'] = 'The date when the capability was created or modified.';
|
||||
$string['privacy:metadata:role_cohortroles'] = 'Roles to cohort';
|
||||
$string['course:togglecompletion'] = 'Allow users to manually complete activities';
|
||||
|
|
|
@ -2460,4 +2460,13 @@ $capabilities = array(
|
|||
'archetypes' => [
|
||||
],
|
||||
],
|
||||
|
||||
// Manual completion toggling.
|
||||
'moodle/course:togglecompletion' => [
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_MODULE,
|
||||
'archetypes' => [
|
||||
'user' => CAP_ALLOW,
|
||||
],
|
||||
],
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue