Skip to content

Commit 7b0ca77

Browse files
Add admin options to set default privacy settings - solves #417
1 parent f59e65b commit 7b0ca77

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

mod_form.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ protected function definition() {
6060

6161
$mform->addElement('hidden', 'cannotchangerespondenttype');
6262
$mform->setType('cannotchangerespondenttype', PARAM_INT);
63-
$mform->addElement('select', 'respondenttype', get_string('respondenttype', 'questionnaire'), $questionnairerespondents);
63+
$selectrespondenttype = $mform->addElement('select', 'respondenttype', get_string('respondenttype', 'questionnaire'),
64+
$questionnairerespondents, array('tabindex' => 0));
65+
$selectrespondenttype->setSelected(get_config('questionnaire', 'respondenttype'));
6466
$mform->addHelpButton('respondenttype', 'respondenttype', 'questionnaire');
6567
$mform->disabledIf('respondenttype', 'cannotchangerespondenttype', 'eq', 1);
6668

67-
$mform->addElement('select', 'resp_view', get_string('responseview', 'questionnaire'), $questionnaireresponseviewers);
69+
$selectrespview = $mform->addElement('select', 'resp_view', get_string('responseview', 'questionnaire'),
70+
$questionnaireresponseviewers, array('tabindex' => 0));
71+
$selectrespview->setSelected(get_config('questionnaire', 'resp_view'));
6872
$mform->addHelpButton('resp_view', 'responseview', 'questionnaire');
6973

7074
$notificationoptions = array(0 => get_string('no'), 1 => get_string('notificationsimple', 'questionnaire'),
@@ -144,6 +148,9 @@ protected function definition() {
144148

145149
$this->standard_coursemodule_elements();
146150

151+
// Apply locked admin settings.
152+
$this->apply_admin_defaults();
153+
147154
// Buttons.
148155
$this->add_action_buttons();
149156
}

settings.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,26 @@
5151

5252
$settings->add(new admin_setting_configcheckbox('questionnaire/allowemailreporting',
5353
get_string('configemailreporting', 'questionnaire'), get_string('configemailreportinglong', 'questionnaire'), 0));
54+
55+
$questionnairerespondents = array (
56+
'fullname' => get_string('respondenttypefullname', 'questionnaire'),
57+
'anonymous' => get_string('respondenttypeanonymous', 'questionnaire'));
58+
59+
$respondenttypesetting = new admin_setting_configselect('questionnaire/respondenttype',
60+
get_string('default').': '.get_string('respondenttype', 'questionnaire'),
61+
get_string('respondenttype_help', 'questionnaire'), 'anonymous', $questionnairerespondents);
62+
$respondenttypesetting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
63+
$settings->add($respondenttypesetting);
64+
65+
$questionnaireresponseviewers = array (
66+
1 => get_string('responseviewstudentswhenanswered', 'questionnaire'),
67+
2 => get_string('responseviewstudentswhenclosed', 'questionnaire'),
68+
3 => get_string('responseviewstudentsalways', 'questionnaire'),
69+
0 => get_string('responseviewstudentsnever', 'questionnaire'));
70+
71+
$respviewsetting = new admin_setting_configselect('questionnaire/resp_view',
72+
get_string('default').': '.get_string('responseview', 'questionnaire'),
73+
get_string('responseview_help', 'questionnaire'), 0, $questionnaireresponseviewers);
74+
$respviewsetting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
75+
$settings->add($respviewsetting);
5476
}

0 commit comments

Comments
 (0)