Commit 6398ff53 authored by Andrew Hancox's avatar Andrew Hancox
Browse files

MDL-49101 core: Add a global admin setting config->requiremodintro

Removed requiremodintro setting from all core activity plugins and replace
with a single global setting.
Deprecated moodleform_mod::add_intro_editor and replaced with
moodleform_mod::standard_intro_elements
parent beaceef9
......@@ -32,6 +32,13 @@ if ($hassiteconfig) {
// activity modules
$ADMIN->add('modules', new admin_category('modsettings', new lang_string('activitymodules')));
$temp = new admin_settingpage('managemodulescommon', new lang_string('commonsettings', 'admin'));
$temp->add(new admin_setting_configcheckbox('requiremodintro',
get_string('requiremodintro', 'admin'), get_string('requiremodintro_desc', 'admin'), 0));
$ADMIN->add('modsettings', $temp);
$ADMIN->add('modsettings', new admin_page_managemods());
foreach (core_plugin_manager::instance()->get_plugins_of_type('mod') as $plugin) {
/** @var \core\plugininfo\mod $plugin */
......
......@@ -648,11 +648,31 @@ abstract class moodleform_mod extends moodleform {
}
}
function add_intro_editor($required=false, $customlabel=null) {
if (!$this->_features->introeditor) {
// intro editor not supported in this module
return;
}
/**
* Add an editor for an activity's introduction field.
* @deprecated since MDL-49101 - use moodleform_mod::standard_intro_elements() instead.
* @param null $required Override system default for requiremodintro
* @param null $customlabel Override default label for editor
* @throws coding_exception
*/
protected function add_intro_editor($required=null, $customlabel=null) {
$str = "Function moodleform_mod::add_intro_editor() is deprecated, use moodleform_mod::standard_intro_elements() instead.";
debugging($str, DEBUG_DEVELOPER);
$this->standard_intro_elements($customlabel);
}
/**
* Add an editor for an activity's introduction field.
*
* @param null $customlabel Override default label for editor
* @throws coding_exception
*/
protected function standard_intro_elements($customlabel=null) {
global $CFG;
$required = $CFG->requiremodintro;
$mform = $this->_form;
$label = is_null($customlabel) ? get_string('moduleintro') : $customlabel;
......
......@@ -37,13 +37,20 @@ Feature: Add activities to courses
And the field "Allow comments on entries" matches value "Yes"
@javascript
Scenario: Add an activity without the required fields
Scenario: Add an activity supplying only the name
When I add a "Database" to section "3" and I fill the form with:
| Name | Test name |
And I press "Save and return to course"
Then I should see "Adding a new"
And I should see "Required"
And I press "Cancel"
Then I should see "Test name"
@javascript @wip
Scenario: Set activity description to required then add an activity supplying only the name
Given I set the following administration settings values:
| requiremodintro | Yes |
When I follow "Home"
And I follow "Course 1"
And I add a "Database" to section "3" and I fill the form with:
| Name | Test name |
Then I should see "Required"
Scenario: Add an activity to a course with Javascript disabled
Then I should see "Add a resource to section 'Topic 1'"
......
......@@ -300,7 +300,6 @@ $string['configrequestedstudentname'] = 'Word for student used in requested cour
$string['configrequestedstudentsname'] = 'Word for students used in requested courses';
$string['configrequestedteachername'] = 'Word for teacher used in requested courses';
$string['configrequestedteachersname'] = 'Word for teachers used in requested courses';
$string['configrequiremodintro'] = 'Disable this option if you do not want to force users to enter description of each activity.';
$string['configrunclamavonupload'] = 'When enabled, clam AV will be used to scan all uploaded files.';
$string['configrunclamonupload'] = 'Run clam AV on file upload? You will need a correct path in pathtoclam for this to work. (Clam AV is a free virus scanner that you can get from http://www.clamav.net/)';
$string['configuserquota'] = 'The maximum number of bytes that a user can store in their own private file area. {$a->bytes} bytes == {$a->displaysize}';
......@@ -911,6 +910,7 @@ $string['reportsmanage'] = 'Manage reports';
$string['requiredentrieschanged'] = '<strong>IMPORTANT - PLEASE READ<br/>(This warning message will only be displayed during this upgrade)</strong><br/>Due to a bug fix, the behaviour of database activities using the \'Required entries\' and \'Required entries before viewing settings\' settings will change. A more detailed explanation of the changes can be read on <a href="http://moodle.org/mod/forum/discuss.php?d=110928" target="_blank">the database module forum</a>. The expected behavior of these settings can also be read on <a href="http://docs.moodle.org/en/Adding/editing_a_database#Required_entries" target="_blank">Moodle Docs</a>.
<br/><br/>This change affects the following databases in your system: (Please save this list now, and after the upgrade, check that these activities still work the way that the teacher intends.)<br/><strong>{$a->text}</strong><br/>';
$string['requiremodintro'] = 'Require activity description';
$string['requiremodintro_desc'] = 'Enable this option if you want to force users to enter description of each activity.';
$string['requires'] = 'Requires';
$string['purgecaches']= 'Purge all caches';
$string['purgecachesconfirm']= 'Moodle can cache themes, javascript, language strings, filtered text, rss feeds and many other pieces of calculated data. Purging these caches will delete that data from the server and force browsers to refetch data, so that you can be sure you are seeing the most up-to-date values produced by the current code. There is no danger in purging caches, but your site may appear slower for a while until the server and clients calculate new information and cache it.';
......
......@@ -4216,5 +4216,10 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2015030400.00);
}
if ($oldversion < 2015033000.00) {
$DB->delete_records('config_plugins', array('name' => 'requiremodintro'));
upgrade_main_savepoint(true, 2015033000.00);
}
return true;
}
......@@ -56,7 +56,7 @@ class mod_assign_mod_form extends moodleform_mod {
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('description', 'assign'));
$this->standard_intro_elements(get_string('description', 'assign'));
$mform->addElement('filemanager', 'introattachments',
get_string('introattachments', 'assign'),
......
......@@ -46,7 +46,7 @@ class mod_book_mod_form extends moodleform_mod {
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro, get_string('moduleintro'));
$this->standard_intro_elements(get_string('moduleintro'));
// Appearance.
$mform->addElement('header', 'appearancehdr', get_string('appearance'));
......
......@@ -29,9 +29,6 @@ if ($ADMIN->fulltree) {
// General settings
$settings->add(new admin_setting_configcheckbox('book/requiremodintro',
get_string('requiremodintro', 'admin'), get_string('configrequiremodintro', 'admin'), 0));
$options = book_get_numbering_types();
$settings->add(new admin_setting_configmultiselect('book/numberingoptions',
......
......@@ -41,7 +41,7 @@ class mod_chat_mod_form extends moodleform_mod {
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('chatintro', 'chat'));
$this->standard_intro_elements(get_string('chatintro', 'chat'));
// Chat sessions.
$mform->addElement('header', 'sessionshdr', get_string('sessions', 'chat'));
......
......@@ -24,7 +24,7 @@ class mod_choice_mod_form extends moodleform_mod {
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('description', 'choice'));
$this->standard_intro_elements(get_string('description', 'choice'));
$mform->addElement('select', 'display', get_string("displaymode","choice"), $CHOICE_DISPLAY);
......
......@@ -24,7 +24,7 @@ class mod_data_mod_form extends moodleform_mod {
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('intro', 'data'));
$this->standard_intro_elements(get_string('intro', 'data'));
// ----------------------------------------------------------------------
$mform->addElement('header', 'entrieshdr', get_string('entries', 'data'));
......
......@@ -46,7 +46,7 @@ class mod_feedback_mod_form extends moodleform_mod {
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('description', 'feedback'));
$this->standard_intro_elements(get_string('description', 'feedback'));
//-------------------------------------------------------------------------------
$mform->addElement('header', 'timinghdr', get_string('availability'));
......
......@@ -44,7 +44,7 @@ class mod_folder_mod_form extends moodleform_mod {
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
$this->standard_intro_elements();
//-------------------------------------------------------
$mform->addElement('header', 'content', get_string('contentheader', 'folder'));
......
......@@ -27,9 +27,6 @@ defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
//--- general settings -----------------------------------------------------------------------------------
$settings->add(new admin_setting_configcheckbox('folder/requiremodintro',
get_string('requiremodintro', 'admin'), get_string('configrequiremodintro', 'admin'), 0));
$settings->add(new admin_setting_configcheckbox('folder/showexpanded',
get_string('showexpanded', 'folder'),
get_string('showexpanded_help', 'folder'), 1));
......
......@@ -46,7 +46,7 @@ class mod_forum_mod_form extends moodleform_mod {
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true, get_string('forumintro', 'forum'));
$this->standard_intro_elements(get_string('forumintro', 'forum'));
$forumtypes = forum_get_forum_types();
core_collator::asort($forumtypes, core_collator::SORT_STRING);
......
......@@ -24,7 +24,7 @@ class mod_glossary_mod_form extends moodleform_mod {
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor(true);
$this->standard_intro_elements();
if (has_capability('mod/glossary:manageentries', context_system::instance())) {
$mform->addElement('checkbox', 'globalglossary', get_string('isglobal', 'glossary'));
......
......@@ -54,7 +54,7 @@ class mod_imscp_mod_form extends moodleform_mod {
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
$this->standard_intro_elements();
// IMS-CP file upload.
$mform->addElement('header', 'content', get_string('contentheader', 'imscp'));
......
......@@ -25,11 +25,6 @@
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
// General settings.
$settings->add(new admin_setting_configcheckbox('imscp/requiremodintro', get_string('requiremodintro', 'admin'),
get_string('configrequiremodintro', 'admin'), 0));
// Modedit defaults.
$settings->add(new admin_setting_heading('imscpmodeditdefaults',
get_string('modeditdefaults', 'admin'),
......
......@@ -34,7 +34,7 @@ class mod_label_mod_form extends moodleform_mod {
$mform = $this->_form;
$mform->addElement('header', 'generalhdr', get_string('general'));
$this->add_intro_editor(true, get_string('labeltext', 'label'));
$this->standard_intro_elements(get_string('labeltext', 'label'));
$this->standard_coursemodule_elements();
......
......@@ -90,7 +90,7 @@ class mod_lesson_mod_form extends moodleform_mod {
}
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$this->add_intro_editor($config->requiremodintro);
$this->standard_intro_elements();
// Appearance.
$mform->addElement('header', 'appearancehdr', get_string('appearance'));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment