#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 1a134d7319
commit 052b7b874f
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( 'mod/customcert:viewallcertificates' => array(
'captype' => 'read', 'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM, '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:addinstance'] = 'Add a new custom certificate instance';
$string['customcert:manage'] = 'Manage a custom certificate'; $string['customcert:manage'] = 'Manage a custom certificate';
$string['customcert:view'] = 'View a custom certificate'; $string['customcert:view'] = 'View a custom certificate';
$string['customcert:viewreport'] = 'View course report';
$string['customcert:viewallcertificates'] = 'View all certificates'; $string['customcert:viewallcertificates'] = 'View all certificates';
$string['customcert:verifycertificate'] = 'Verify a certificate'; $string['customcert:verifycertificate'] = 'Verify a certificate';
$string['deletecertpage'] = 'Delete certificate page'; $string['deletecertpage'] = 'Delete certificate page';

View file

@ -44,7 +44,7 @@ require_login($course, false, $cm);
// Check capabilities. // Check capabilities.
$context = context_module::instance($cm->id); $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. // Check if we requested to download another user's certificate.
if ($downloadcert) { if ($downloadcert) {

View file

@ -24,10 +24,10 @@
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
$plugin->version = 2017050502; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2017050503; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2017050500; // Requires this Moodle version (3.3). $plugin->requires = 2017050500; // Requires this Moodle version (3.3).
$plugin->cron = 0; // Period for cron to check this module (secs). $plugin->cron = 0; // Period for cron to check this module (secs).
$plugin->component = 'mod_customcert'; $plugin->component = 'mod_customcert';
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;
$plugin->release = "3.3 release (Build: 2017050502)"; // User-friendly version number. $plugin->release = "3.3 release (Build: 2017050503)"; // 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. // Generate the link to the report if there are issues to display.
$reportlink = ''; $reportlink = '';
if (has_capability('mod/customcert:manage', $context)) { if (has_capability('mod/customcert:viewreport', $context)) {
// Get the total number of issues. // Get the total number of issues.
$numissues = \mod_customcert\certificate::get_number_of_issues($customcert->id, $cm, $groupmode); $numissues = \mod_customcert\certificate::get_number_of_issues($customcert->id, $cm, $groupmode);
$href = new moodle_urL('/mod/customcert/report.php', array('id' => $cm->id)); $href = new moodle_urL('/mod/customcert/report.php', array('id' => $cm->id));