-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New feature: Add default value at the global level/plugin's settings page. #14
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good change, in principle. Thanks. However, it needs to be implemented consistently with other similar quiz settings, and the implementation needs to be technically right before it can be merged.
rule.php
Outdated
@@ -86,22 +86,19 @@ public static function add_settings_form_fields( | |||
0 => get_string('notrequired', 'quizaccess_honestycheck'), | |||
1 => get_string('honestycheckrequiredoption', 'quizaccess_honestycheck'), | |||
)); | |||
$default = get_config('quizaccess_honestycheck', 'honestycheckrequired'); | |||
$mform->setDefault('honestycheckrequired', $default); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of the lcoal variable $default here? Much better to put the $default inline in the next line.
settings.php
Outdated
|
||
$settings->add(new admin_setting_configselect( | ||
'quizaccess_honestycheck/honestycheckrequired', | ||
get_string('honestycheckrequired', 'quizaccess_honestycheck'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In settings.php, you shoudl use new lang_string, not get_string, for performance reasons.
settings.php
Outdated
'quizaccess_honestycheck/honestycheckrequired', | ||
get_string('honestycheckrequired', 'quizaccess_honestycheck'), | ||
get_string('honestycheckrequired', 'quizaccess_honestycheck'), | ||
1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the default 1 might be what you want, but you are contributing to an open source project. For most people, the default of 0 is more appropriate, so we should set that.
settings.php
Outdated
0 => get_string('notrequired', 'quizaccess_honestycheck'), | ||
1 => get_string('honestycheckrequiredoption', 'quizaccess_honestycheck') | ||
) | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be consistent with what is done for all the other quiz settings, and give the admin control over whether the setting is advanced or locked using
$setting->set_advanced_flag_options(admin_setting_flag::ENABLED, false);
$setting->set_locked_flag_options(admin_setting_flag::ENABLED, false);
(Look at mod/quiz/settings.php if you don't understand what i mean.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed this as well
f9b7913
to
6ee51ae
Compare
Hi Tim, |
Hi,
This will create a settings page for the plugin to save the default value of honestycheckrequired.
The new instances of a quiz will have this default value set at the time of creation.
Regards,
Sumaiya