#179 Add possibility to selectively disable activity instance settings
This commit is contained in:
parent
e7e2106efb
commit
f42a0ac394
3 changed files with 131 additions and 21 deletions
|
@ -96,4 +96,64 @@ $capabilities = array(
|
||||||
'manager' => CAP_ALLOW
|
'manager' => CAP_ALLOW
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'mod/customcert:manageemailstudents' => array(
|
||||||
|
'captype' => 'write',
|
||||||
|
'contextlevel' => CONTEXT_COURSE,
|
||||||
|
'archetypes' => array(
|
||||||
|
'editingteacher' => CAP_ALLOW,
|
||||||
|
'manager' => CAP_ALLOW
|
||||||
|
),
|
||||||
|
'clonepermissionsfrom' => 'moodle/course:manageactivities'
|
||||||
|
),
|
||||||
|
|
||||||
|
'mod/customcert:manageemailteachers' => array(
|
||||||
|
'captype' => 'write',
|
||||||
|
'contextlevel' => CONTEXT_COURSE,
|
||||||
|
'archetypes' => array(
|
||||||
|
'editingteacher' => CAP_ALLOW,
|
||||||
|
'manager' => CAP_ALLOW
|
||||||
|
),
|
||||||
|
'clonepermissionsfrom' => 'moodle/course:manageactivities'
|
||||||
|
),
|
||||||
|
|
||||||
|
'mod/customcert:manageemailothers' => array(
|
||||||
|
'captype' => 'write',
|
||||||
|
'contextlevel' => CONTEXT_COURSE,
|
||||||
|
'archetypes' => array(
|
||||||
|
'editingteacher' => CAP_ALLOW,
|
||||||
|
'manager' => CAP_ALLOW
|
||||||
|
),
|
||||||
|
'clonepermissionsfrom' => 'moodle/course:manageactivities'
|
||||||
|
),
|
||||||
|
|
||||||
|
'mod/customcert:manageverifyany' => array(
|
||||||
|
'captype' => 'write',
|
||||||
|
'contextlevel' => CONTEXT_COURSE,
|
||||||
|
'archetypes' => array(
|
||||||
|
'editingteacher' => CAP_ALLOW,
|
||||||
|
'manager' => CAP_ALLOW
|
||||||
|
),
|
||||||
|
'clonepermissionsfrom' => 'moodle/course:manageactivities'
|
||||||
|
),
|
||||||
|
|
||||||
|
'mod/customcert:managerequiredtime' => array(
|
||||||
|
'captype' => 'write',
|
||||||
|
'contextlevel' => CONTEXT_COURSE,
|
||||||
|
'archetypes' => array(
|
||||||
|
'editingteacher' => CAP_ALLOW,
|
||||||
|
'manager' => CAP_ALLOW
|
||||||
|
),
|
||||||
|
'clonepermissionsfrom' => 'moodle/course:manageactivities'
|
||||||
|
),
|
||||||
|
|
||||||
|
'mod/customcert:manageprotection' => array(
|
||||||
|
'captype' => 'write',
|
||||||
|
'contextlevel' => CONTEXT_COURSE,
|
||||||
|
'archetypes' => array(
|
||||||
|
'editingteacher' => CAP_ALLOW,
|
||||||
|
'manager' => CAP_ALLOW
|
||||||
|
),
|
||||||
|
'clonepermissionsfrom' => 'moodle/course:manageactivities'
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -35,6 +35,12 @@ the certificate.';
|
||||||
$string['createtemplate'] = 'Create template';
|
$string['createtemplate'] = 'Create template';
|
||||||
$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:manageemailstudents'] = 'Manage email students setting';
|
||||||
|
$string['customcert:manageemailteachers'] = 'Manage email teachers setting';
|
||||||
|
$string['customcert:manageemailothers'] = 'Manage email others setting';
|
||||||
|
$string['customcert:manageverifyany'] = 'Manage verification setting';
|
||||||
|
$string['customcert:managerequiredtime'] = 'Manage time required setting';
|
||||||
|
$string['customcert:manageprotection'] = 'Manage protection setting';
|
||||||
$string['customcert:view'] = 'View a custom certificate';
|
$string['customcert:view'] = 'View a custom certificate';
|
||||||
$string['customcert:viewreport'] = 'View course report';
|
$string['customcert:viewreport'] = 'View course report';
|
||||||
$string['customcert:viewallcertificates'] = 'View all certificates';
|
$string['customcert:viewallcertificates'] = 'View all certificates';
|
||||||
|
|
86
mod_form.php
86
mod_form.php
|
@ -55,33 +55,77 @@ class mod_customcert_mod_form extends moodleform_mod {
|
||||||
|
|
||||||
$this->standard_intro_elements(get_string('description', 'customcert'));
|
$this->standard_intro_elements(get_string('description', 'customcert'));
|
||||||
|
|
||||||
$mform->addElement('header', 'options', get_string('options', 'customcert'));
|
$optionsheader = $mform->createElement('header', 'options', get_string('options', 'customcert'));
|
||||||
|
|
||||||
$mform->addElement('selectyesno', 'emailstudents', get_string('emailstudents', 'customcert'));
|
if (has_capability('mod/customcert:manageemailstudents', $this->get_context())) {
|
||||||
$mform->setType('emailstudents', 0);
|
$mform->addElement('selectyesno', 'emailstudents', get_string('emailstudents', 'customcert'));
|
||||||
$mform->addHelpButton('emailstudents', 'emailstudents', 'customcert');
|
$mform->setDefault('emailstudents', 0);
|
||||||
|
$mform->addHelpButton('emailstudents', 'emailstudents', 'customcert');
|
||||||
|
$firstoption = 'emailstudents';
|
||||||
|
} else {
|
||||||
|
$mform->addElement('hidden', 'emailstudents', 0);
|
||||||
|
$mform->setType('emailstudents', PARAM_INT);
|
||||||
|
}
|
||||||
|
|
||||||
$mform->addElement('selectyesno', 'emailteachers', get_string('emailteachers', 'customcert'));
|
if (has_capability('mod/customcert:manageemailteachers', $this->get_context())) {
|
||||||
$mform->setDefault('emailteachers', 0);
|
$mform->addElement('selectyesno', 'emailteachers', get_string('emailteachers', 'customcert'));
|
||||||
$mform->addHelpButton('emailteachers', 'emailteachers', 'customcert');
|
$mform->setDefault('emailteachers', 0);
|
||||||
|
$mform->addHelpButton('emailteachers', 'emailteachers', 'customcert');
|
||||||
|
$firstoption = empty($firstoption) ? 'emailteachers' : $firstoption;
|
||||||
|
} else {
|
||||||
|
$mform->addElement('hidden', 'emailteachers', 0);
|
||||||
|
$mform->setType('emailstudents', PARAM_INT);
|
||||||
|
}
|
||||||
|
|
||||||
$mform->addElement('text', 'emailothers', get_string('emailothers', 'customcert'), array('size' => '40'));
|
if (has_capability('mod/customcert:manageemailothers', $this->get_context())) {
|
||||||
$mform->setType('emailothers', PARAM_TEXT);
|
$mform->addElement('text', 'emailothers', get_string('emailothers', 'customcert'), array('size' => '40'));
|
||||||
$mform->addHelpButton('emailothers', 'emailothers', 'customcert');
|
$mform->setType('emailothers', PARAM_TEXT);
|
||||||
|
$mform->addHelpButton('emailothers', 'emailothers', 'customcert');
|
||||||
|
$firstoption = empty($firstoption) ? 'emailothers' : $firstoption;
|
||||||
|
} else {
|
||||||
|
$mform->addElement('hidden', 'emailothers', '');
|
||||||
|
$mform->setType('emailothers', PARAM_TEXT);
|
||||||
|
}
|
||||||
|
|
||||||
$mform->addElement('selectyesno', 'verifyany', get_string('verifycertificateanyone', 'customcert'));
|
if (has_capability('mod/customcert:manageverifyany', $this->get_context())) {
|
||||||
$mform->setType('verifyany', 0);
|
$mform->addElement('selectyesno', 'verifyany', get_string('verifycertificateanyone', 'customcert'));
|
||||||
$mform->addHelpButton('verifyany', 'verifycertificateanyone', 'customcert');
|
$mform->setType('verifyany', 0);
|
||||||
|
$mform->addHelpButton('verifyany', 'verifycertificateanyone', 'customcert');
|
||||||
|
$firstoption = empty($firstoption) ? 'verifyany' : $firstoption;
|
||||||
|
} else {
|
||||||
|
$mform->addElement('hidden', 'verifyany', 0);
|
||||||
|
$mform->setType('emailothers', PARAM_INT);
|
||||||
|
}
|
||||||
|
|
||||||
$mform->addElement('text', 'requiredtime', get_string('coursetimereq', 'customcert'), array('size' => '3'));
|
if (has_capability('mod/customcert:managerequiredtime', $this->get_context())) {
|
||||||
$mform->setType('requiredtime', PARAM_INT);
|
$mform->addElement('text', 'requiredtime', get_string('coursetimereq', 'customcert'), array('size' => '3'));
|
||||||
$mform->addHelpButton('requiredtime', 'coursetimereq', 'customcert');
|
$mform->setType('requiredtime', PARAM_INT);
|
||||||
|
$mform->addHelpButton('requiredtime', 'coursetimereq', 'customcert');
|
||||||
|
$firstoption = empty($firstoption) ? 'requiredtime' : $firstoption;
|
||||||
|
} else {
|
||||||
|
$mform->addElement('hidden', 'requiredtime', 0);
|
||||||
|
$mform->setType('requiredtime', PARAM_INT);
|
||||||
|
}
|
||||||
|
|
||||||
$mform->addElement('checkbox', 'protection_print', get_string('setprotection', 'customcert'),
|
if (has_capability('mod/customcert:manageprotection', $this->get_context())) {
|
||||||
get_string('print', 'customcert'));
|
$mform->addElement('checkbox', 'protection_print', get_string('setprotection', 'customcert'),
|
||||||
$mform->addElement('checkbox', 'protection_modify', '', get_string('modify', 'customcert'));
|
get_string('print', 'customcert'));
|
||||||
$mform->addElement('checkbox', 'protection_copy', '', get_string('copy', 'customcert'));
|
$mform->addElement('checkbox', 'protection_modify', '', get_string('modify', 'customcert'));
|
||||||
$mform->addHelpButton('protection_print', 'setprotection', 'customcert');
|
$mform->addElement('checkbox', 'protection_copy', '', get_string('copy', 'customcert'));
|
||||||
|
$mform->addHelpButton('protection_print', 'setprotection', 'customcert');
|
||||||
|
$firstoption = empty($firstoption) ? 'protection_print' : $firstoption;
|
||||||
|
} else {
|
||||||
|
$mform->addElement('hidden', 'protection_print', 0);
|
||||||
|
$mform->addElement('hidden', 'protection_modify', 0);
|
||||||
|
$mform->addElement('hidden', 'protection_copy', 0);
|
||||||
|
$mform->setType('protection_print', PARAM_INT);
|
||||||
|
$mform->setType('protection_modify', PARAM_INT);
|
||||||
|
$mform->setType('protection_copy', PARAM_INT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($firstoption)) {
|
||||||
|
$mform->insertElementBefore($optionsheader, $firstoption);
|
||||||
|
}
|
||||||
|
|
||||||
$this->standard_coursemodule_elements();
|
$this->standard_coursemodule_elements();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue