New feature: Add default value at the global level/plugin's settings page.#14
New feature: Add default value at the global level/plugin's settings page.#14sumaiyamannan wants to merge 1 commit intomoodleou:mainfrom
Conversation
timhunt
left a comment
There was a problem hiding this comment.
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
| 1 => get_string('honestycheckrequiredoption', 'quizaccess_honestycheck'), | ||
| )); | ||
| $default = get_config('quizaccess_honestycheck', 'honestycheckrequired'); | ||
| $mform->setDefault('honestycheckrequired', $default); |
There was a problem hiding this comment.
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.
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.
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.
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.)
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