Skip to content

Commit

Permalink
Add admin options to set default privacy settings - solves #417
Browse files Browse the repository at this point in the history
  • Loading branch information
melanietreitinger committed Feb 21, 2023
1 parent f59e65b commit 7b0ca77
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ protected function definition() {

$mform->addElement('hidden', 'cannotchangerespondenttype');
$mform->setType('cannotchangerespondenttype', PARAM_INT);
$mform->addElement('select', 'respondenttype', get_string('respondenttype', 'questionnaire'), $questionnairerespondents);
$selectrespondenttype = $mform->addElement('select', 'respondenttype', get_string('respondenttype', 'questionnaire'),
$questionnairerespondents, array('tabindex' => 0));
$selectrespondenttype->setSelected(get_config('questionnaire', 'respondenttype'));
$mform->addHelpButton('respondenttype', 'respondenttype', 'questionnaire');
$mform->disabledIf('respondenttype', 'cannotchangerespondenttype', 'eq', 1);

$mform->addElement('select', 'resp_view', get_string('responseview', 'questionnaire'), $questionnaireresponseviewers);
$selectrespview = $mform->addElement('select', 'resp_view', get_string('responseview', 'questionnaire'),
$questionnaireresponseviewers, array('tabindex' => 0));
$selectrespview->setSelected(get_config('questionnaire', 'resp_view'));
$mform->addHelpButton('resp_view', 'responseview', 'questionnaire');

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

$this->standard_coursemodule_elements();

// Apply locked admin settings.
$this->apply_admin_defaults();

// Buttons.
$this->add_action_buttons();
}
Expand Down
22 changes: 22 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,26 @@

$settings->add(new admin_setting_configcheckbox('questionnaire/allowemailreporting',
get_string('configemailreporting', 'questionnaire'), get_string('configemailreportinglong', 'questionnaire'), 0));

$questionnairerespondents = array (
'fullname' => get_string('respondenttypefullname', 'questionnaire'),
'anonymous' => get_string('respondenttypeanonymous', 'questionnaire'));

$respondenttypesetting = new admin_setting_configselect('questionnaire/respondenttype',
get_string('default').': '.get_string('respondenttype', 'questionnaire'),
get_string('respondenttype_help', 'questionnaire'), 'anonymous', $questionnairerespondents);
$respondenttypesetting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($respondenttypesetting);

$questionnaireresponseviewers = array (
1 => get_string('responseviewstudentswhenanswered', 'questionnaire'),
2 => get_string('responseviewstudentswhenclosed', 'questionnaire'),
3 => get_string('responseviewstudentsalways', 'questionnaire'),
0 => get_string('responseviewstudentsnever', 'questionnaire'));

$respviewsetting = new admin_setting_configselect('questionnaire/resp_view',
get_string('default').': '.get_string('responseview', 'questionnaire'),
get_string('responseview_help', 'questionnaire'), 0, $questionnaireresponseviewers);
$respviewsetting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
$settings->add($respviewsetting);
}

0 comments on commit 7b0ca77

Please sign in to comment.