#85 Added new capability for viewing the course report

This commit is contained in:
Mark Nelson 2017-06-02 12:42:04 +08:00
parent 07f506293d
commit b2b820cc9a
5 changed files with 16 additions and 4 deletions

View file

@ -60,6 +60,17 @@ $capabilities = array(
)
),
'mod/customcert:viewreport' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
),
'mod/customcert:viewallcertificates' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,

View file

@ -36,6 +36,7 @@ $string['customcertreport'] = 'Custom certificate report';
$string['customcert:addinstance'] = 'Add a new custom certificate instance';
$string['customcert:manage'] = 'Manage a custom certificate';
$string['customcert:view'] = 'View a custom certificate';
$string['customcert:viewreport'] = 'View course report';
$string['customcert:viewallcertificates'] = 'View all certificates';
$string['customcert:verifycertificate'] = 'Verify a certificate';
$string['deletecertpage'] = 'Delete certificate page';

View file

@ -44,7 +44,7 @@ require_login($course, false, $cm);
// Check capabilities.
$context = context_module::instance($cm->id);
require_capability('mod/customcert:manage', $context);
require_capability('mod/customcert:viewreport', $context);
// Check if we requested to download another user's certificate.
if ($downloadcert) {

View file

@ -24,10 +24,10 @@
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
$plugin->version = 2016120508; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2016120509; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2016120500; // Requires this Moodle version (3.2).
$plugin->cron = 0; // Period for cron to check this module (secs).
$plugin->component = 'mod_customcert';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = "3.2 release (Build: 2016120508)"; // User-friendly version number.
$plugin->release = "3.2 release (Build: 2016120509)"; // User-friendly version number.

View file

@ -68,7 +68,7 @@ if (empty($action)) {
// Generate the link to the report if there are issues to display.
$reportlink = '';
if (has_capability('mod/customcert:manage', $context)) {
if (has_capability('mod/customcert:viewreport', $context)) {
// Get the total number of issues.
$numissues = \mod_customcert\certificate::get_number_of_issues($customcert->id, $cm, $groupmode);
$href = new moodle_urL('/mod/customcert/report.php', array('id' => $cm->id));