#180 Add possibility to set default values of activity instance

This commit is contained in:
Dmitrii Metelkin 2018-07-23 16:17:30 +10:00 committed by Mark Nelson
parent f42a0ac394
commit 6c07679c2c
3 changed files with 62 additions and 20 deletions

View file

@ -134,6 +134,12 @@ $string['posx'] = 'Position X';
$string['posx_help'] = 'This is the position in mm from the top left corner you wish the element\'s reference point to locate in the x direction.'; $string['posx_help'] = 'This is the position in mm from the top left corner you wish the element\'s reference point to locate in the x direction.';
$string['posy'] = 'Position Y'; $string['posy'] = 'Position Y';
$string['posy_help'] = 'This is the position in mm from the top left corner you wish the element\'s reference point to locate in the y direction.'; $string['posy_help'] = 'This is the position in mm from the top left corner you wish the element\'s reference point to locate in the y direction.';
$string['preventcopy'] = 'Prevent copy';
$string['preventcopy_desc'] = 'Enable protection from print action.';
$string['preventprint'] = 'Prevent print';
$string['preventprint_desc'] = 'Enable protection from modify action.';
$string['preventmodify'] = 'Prevent modify';
$string['preventmodify_desc'] = 'Enable protection from copy action.';
$string['print'] = 'Print'; $string['print'] = 'Print';
$string['privacy:metadata:customcert_issues'] = 'The list of issued certificates'; $string['privacy:metadata:customcert_issues'] = 'The list of issued certificates';
$string['privacy:metadata:customcert_issues:code'] = 'The code that belongs to the certificate'; $string['privacy:metadata:customcert_issues:code'] = 'The code that belongs to the certificate';

View file

@ -59,53 +59,53 @@ class mod_customcert_mod_form extends moodleform_mod {
if (has_capability('mod/customcert:manageemailstudents', $this->get_context())) { if (has_capability('mod/customcert:manageemailstudents', $this->get_context())) {
$mform->addElement('selectyesno', 'emailstudents', get_string('emailstudents', 'customcert')); $mform->addElement('selectyesno', 'emailstudents', get_string('emailstudents', 'customcert'));
$mform->setDefault('emailstudents', 0); $mform->setDefault('emailstudents', get_config('customcert', 'emailstudents'));
$mform->addHelpButton('emailstudents', 'emailstudents', 'customcert'); $mform->addHelpButton('emailstudents', 'emailstudents', 'customcert');
$firstoption = 'emailstudents'; $firstoption = 'emailstudents';
} else { } else {
$mform->addElement('hidden', 'emailstudents', 0); $mform->addElement('hidden', 'emailstudents', get_config('customcert', 'emailstudents'));
$mform->setType('emailstudents', PARAM_INT);
} }
$mform->setType('emailstudents', PARAM_INT);
if (has_capability('mod/customcert:manageemailteachers', $this->get_context())) { if (has_capability('mod/customcert:manageemailteachers', $this->get_context())) {
$mform->addElement('selectyesno', 'emailteachers', get_string('emailteachers', 'customcert')); $mform->addElement('selectyesno', 'emailteachers', get_string('emailteachers', 'customcert'));
$mform->setDefault('emailteachers', 0); $mform->setDefault('emailteachers', get_config('customcert', 'emailteachers'));
$mform->addHelpButton('emailteachers', 'emailteachers', 'customcert'); $mform->addHelpButton('emailteachers', 'emailteachers', 'customcert');
$firstoption = empty($firstoption) ? 'emailteachers' : $firstoption; $firstoption = empty($firstoption) ? 'emailteachers' : $firstoption;
} else { } else {
$mform->addElement('hidden', 'emailteachers', 0); $mform->addElement('hidden', 'emailteachers', get_config('customcert', 'emailteachers'));
$mform->setType('emailstudents', PARAM_INT);
} }
$mform->setType('emailteachers', PARAM_INT);
if (has_capability('mod/customcert:manageemailothers', $this->get_context())) { if (has_capability('mod/customcert:manageemailothers', $this->get_context())) {
$mform->addElement('text', 'emailothers', get_string('emailothers', 'customcert'), array('size' => '40')); $mform->addElement('text', 'emailothers', get_string('emailothers', 'customcert'), array('size' => '40'));
$mform->setType('emailothers', PARAM_TEXT);
$mform->addHelpButton('emailothers', 'emailothers', 'customcert'); $mform->addHelpButton('emailothers', 'emailothers', 'customcert');
$mform->setDefault('emailothers', get_config('customcert', 'emailothers'));
$firstoption = empty($firstoption) ? 'emailothers' : $firstoption; $firstoption = empty($firstoption) ? 'emailothers' : $firstoption;
} else { } else {
$mform->addElement('hidden', 'emailothers', ''); $mform->addElement('hidden', 'emailothers', get_config('customcert', 'emailothers'));
$mform->setType('emailothers', PARAM_TEXT);
} }
$mform->setType('emailothers', PARAM_TEXT);
if (has_capability('mod/customcert:manageverifyany', $this->get_context())) { if (has_capability('mod/customcert:manageverifyany', $this->get_context())) {
$mform->addElement('selectyesno', 'verifyany', get_string('verifycertificateanyone', 'customcert')); $mform->addElement('selectyesno', 'verifyany', get_string('verifycertificateanyone', 'customcert'));
$mform->setType('verifyany', 0);
$mform->addHelpButton('verifyany', 'verifycertificateanyone', 'customcert'); $mform->addHelpButton('verifyany', 'verifycertificateanyone', 'customcert');
$mform->setDefault('verifyany', get_config('customcert', 'verifyany'));
$firstoption = empty($firstoption) ? 'verifyany' : $firstoption; $firstoption = empty($firstoption) ? 'verifyany' : $firstoption;
} else { } else {
$mform->addElement('hidden', 'verifyany', 0); $mform->addElement('hidden', 'verifyany', get_config('customcert', 'verifyany'));
$mform->setType('emailothers', PARAM_INT);
} }
$mform->setType('verifyany', PARAM_INT);
if (has_capability('mod/customcert:managerequiredtime', $this->get_context())) { if (has_capability('mod/customcert:managerequiredtime', $this->get_context())) {
$mform->addElement('text', 'requiredtime', get_string('coursetimereq', 'customcert'), array('size' => '3')); $mform->addElement('text', 'requiredtime', get_string('coursetimereq', 'customcert'), array('size' => '3'));
$mform->setType('requiredtime', PARAM_INT);
$mform->addHelpButton('requiredtime', 'coursetimereq', 'customcert'); $mform->addHelpButton('requiredtime', 'coursetimereq', 'customcert');
$mform->setDefault('requiredtime', get_config('customcert', 'coursetimereq'));
$firstoption = empty($firstoption) ? 'requiredtime' : $firstoption; $firstoption = empty($firstoption) ? 'requiredtime' : $firstoption;
} else { } else {
$mform->addElement('hidden', 'requiredtime', 0); $mform->addElement('hidden', 'requiredtime', 0);
$mform->setType('requiredtime', PARAM_INT);
} }
$mform->setType('requiredtime', PARAM_INT);
if (has_capability('mod/customcert:manageprotection', $this->get_context())) { if (has_capability('mod/customcert:manageprotection', $this->get_context())) {
$mform->addElement('checkbox', 'protection_print', get_string('setprotection', 'customcert'), $mform->addElement('checkbox', 'protection_print', get_string('setprotection', 'customcert'),
@ -113,15 +113,18 @@ class mod_customcert_mod_form extends moodleform_mod {
$mform->addElement('checkbox', 'protection_modify', '', get_string('modify', 'customcert')); $mform->addElement('checkbox', 'protection_modify', '', get_string('modify', 'customcert'));
$mform->addElement('checkbox', 'protection_copy', '', get_string('copy', 'customcert')); $mform->addElement('checkbox', 'protection_copy', '', get_string('copy', 'customcert'));
$mform->addHelpButton('protection_print', 'setprotection', 'customcert'); $mform->addHelpButton('protection_print', 'setprotection', 'customcert');
$mform->setDefault('protection_print', get_config('customcert', 'protection_print'));
$mform->setDefault('protection_modify', get_config('customcert', 'protection_modify'));
$mform->setDefault('protection_copy', get_config('customcert', 'protection_copy'));
$firstoption = empty($firstoption) ? 'protection_print' : $firstoption; $firstoption = empty($firstoption) ? 'protection_print' : $firstoption;
} else { } else {
$mform->addElement('hidden', 'protection_print', 0); $mform->addElement('hidden', 'protection_print', get_config('customcert', 'protection_print'));
$mform->addElement('hidden', 'protection_modify', 0); $mform->addElement('hidden', 'protection_modify', get_config('customcert', 'protection_modify'));
$mform->addElement('hidden', 'protection_copy', 0); $mform->addElement('hidden', 'protection_copy', get_config('customcert', 'protection_copy'));
$mform->setType('protection_print', PARAM_INT);
$mform->setType('protection_modify', PARAM_INT);
$mform->setType('protection_copy', PARAM_INT);
} }
$mform->setType('protection_print', PARAM_BOOL);
$mform->setType('protection_modify', PARAM_BOOL);
$mform->setType('protection_copy', PARAM_BOOL);
if (!empty($firstoption)) { if (!empty($firstoption)) {
$mform->insertElementBefore($optionsheader, $firstoption); $mform->insertElementBefore($optionsheader, $firstoption);

View file

@ -50,6 +50,39 @@ $settings->add(new \mod_customcert\admin_setting_link('customcert/managetemplate
$settings->add(new \mod_customcert\admin_setting_link('customcert/uploadimage', $settings->add(new \mod_customcert\admin_setting_link('customcert/uploadimage',
get_string('uploadimage', 'customcert'), get_string('uploadimagedesc', 'customcert'), get_string('uploadimage', 'customcert'), get_string('uploadimagedesc', 'customcert'),
get_string('uploadimage', 'customcert'), new moodle_url('/mod/customcert/upload_image.php'), '')); get_string('uploadimage', 'customcert'), new moodle_url('/mod/customcert/upload_image.php'), ''));
$settings->add(new admin_setting_heading('defaults',
get_string('modeditdefaults', 'admin'), get_string('condifmodeditdefaults', 'admin')));
$yesnooptions = [
0 => get_string('no'),
1 => get_string('yes'),
];
$settings->add(new admin_setting_configselect('customcert/emailstudents',
get_string('emailstudents', 'customcert'), get_string('emailstudents_help', 'customcert'), 0, $yesnooptions));
$settings->add(new admin_setting_configselect('customcert/emailteachers',
get_string('emailteachers', 'customcert'), get_string('emailteachers_help', 'customcert'), 0, $yesnooptions));
$settings->add(new admin_setting_configtext('customcert/emailothers',
get_string('emailothers', 'customcert'), get_string('emailothers_help', 'customcert'), '', PARAM_TEXT));
$settings->add(new admin_setting_configselect('customcert/verifyany',
get_string('verifycertificateanyone', 'customcert'), get_string('verifycertificateanyone_help', 'customcert'),
0, $yesnooptions));
$settings->add(new admin_setting_configtext('customcert/requiredtime',
get_string('coursetimereq', 'customcert'), get_string('coursetimereq_help', 'customcert'), 0, PARAM_INT));
$settings->add(new admin_setting_configcheckbox('customcert/protection_print',
get_string('preventprint', 'customcert'),
get_string('preventprint_desc', 'customcert'),
0));
$settings->add(new admin_setting_configcheckbox('customcert/protection_modify',
get_string('preventmodify', 'customcert'),
get_string('preventmodify_desc', 'customcert'),
0));
$settings->add(new admin_setting_configcheckbox('customcert/protection_copy',
get_string('preventcopy', 'customcert'),
get_string('preventcopy_desc', 'customcert'),
0));
$ADMIN->add('customcert', $settings); $ADMIN->add('customcert', $settings);
// Element plugin settings. // Element plugin settings.