mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch '67278-master-categories-selector' of https://github.com/DSI-Universite-Rennes2/moodle into master
This commit is contained in:
commit
cf4841cfdb
@ -83,7 +83,7 @@ class tool_uploadcourse_step2_form extends tool_uploadcourse_base_form {
|
||||
$mform->setExpanded('defaultheader', true);
|
||||
|
||||
$displaylist = core_course_category::make_categories_list('moodle/course:create');
|
||||
$mform->addElement('select', 'defaults[category]', get_string('coursecategory'), $displaylist);
|
||||
$mform->addElement('autocomplete', 'defaults[category]', get_string('coursecategory'), $displaylist);
|
||||
$mform->addHelpButton('defaults[category]', 'coursecategory');
|
||||
|
||||
$choices = array();
|
||||
|
@ -106,7 +106,7 @@ class copy_form extends \moodleform {
|
||||
// Always keep current category.
|
||||
$displaylist[$course->category] = \core_course_category::get($course->category, MUST_EXIST, true)->get_formatted_name();
|
||||
}
|
||||
$mform->addElement('select', 'category', get_string('coursecategory'), $displaylist);
|
||||
$mform->addElement('autocomplete', 'category', get_string('coursecategory'), $displaylist);
|
||||
$mform->addHelpButton('category', 'coursecategory');
|
||||
|
||||
// Course visibility.
|
||||
|
@ -94,7 +94,7 @@ trait eventtype {
|
||||
$categoryoptions[$id] = $category;
|
||||
}
|
||||
|
||||
$mform->addElement('select', 'categoryid', get_string('category'), $categoryoptions);
|
||||
$mform->addElement('autocomplete', 'categoryid', get_string('category'), $categoryoptions);
|
||||
$mform->hideIf('categoryid', 'eventtype', 'noteq', 'category');
|
||||
}
|
||||
|
||||
|
@ -199,10 +199,10 @@ Feature: Perform basic calendar functionality
|
||||
And I am viewing site calendar
|
||||
And I click on "New event" "button"
|
||||
And I set the field "Type of event" to "Course"
|
||||
When I open the autocomplete suggestions list
|
||||
Then I should see "Course 1" in the ".form-autocomplete-suggestions" "css_element"
|
||||
And I should not see "Course 2" in the ".form-autocomplete-suggestions" "css_element"
|
||||
And I should not see "Course 3" in the ".form-autocomplete-suggestions" "css_element"
|
||||
When I expand the "Course" autocomplete
|
||||
Then "Course 1" "autocomplete_suggestions" should exist
|
||||
And "Course 2" "autocomplete_suggestions" should not exist
|
||||
And "Course 3" "autocomplete_suggestions" should not exist
|
||||
And I click on "Close" "button"
|
||||
And I am on site homepage
|
||||
And I navigate to "Appearance > Calendar" in site administration
|
||||
@ -211,10 +211,10 @@ Feature: Perform basic calendar functionality
|
||||
And I am viewing site calendar
|
||||
And I click on "New event" "button"
|
||||
And I set the field "Type of event" to "Course"
|
||||
When I open the autocomplete suggestions list
|
||||
Then I should see "Course 1" in the ".form-autocomplete-suggestions" "css_element"
|
||||
And I should see "Course 2" in the ".form-autocomplete-suggestions" "css_element"
|
||||
And I should see "Course 3" in the ".form-autocomplete-suggestions" "css_element"
|
||||
When I expand the "Course" autocomplete
|
||||
Then "Course 1" "autocomplete_suggestions" should exist
|
||||
And "Course 2" "autocomplete_suggestions" should exist
|
||||
And "Course 3" "autocomplete_suggestions" should exist
|
||||
|
||||
@javascript
|
||||
Scenario: Students can only see user event type by default.
|
||||
|
@ -43,7 +43,7 @@ class cohort_edit_form extends moodleform {
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
|
||||
$options = $this->get_category_options($cohort->contextid);
|
||||
$mform->addElement('select', 'contextid', get_string('context', 'role'), $options);
|
||||
$mform->addElement('autocomplete', 'contextid', get_string('context', 'role'), $options);
|
||||
|
||||
$mform->addElement('text', 'idnumber', get_string('idnumber', 'cohort'), 'maxlength="254" size="50"');
|
||||
$mform->setType('idnumber', PARAM_RAW); // Idnumbers are plain text, must not be changed.
|
||||
|
@ -21,6 +21,7 @@ Feature: Add cohorts of users
|
||||
| Description | Test cohort description |
|
||||
And I press "Save changes"
|
||||
|
||||
@javascript
|
||||
Scenario: Add a cohort
|
||||
When I follow "Cohorts"
|
||||
Then I should see "Test cohort name"
|
||||
@ -28,6 +29,7 @@ Feature: Add cohorts of users
|
||||
And I should see "Test cohort description"
|
||||
And I should see "Created manually"
|
||||
|
||||
@javascript
|
||||
Scenario: Add users to a cohort selecting them from the system users list
|
||||
When I add "First User (first@example.com)" user to "333" cohort members
|
||||
And I add "Second User (second@example.com)" user to "333" cohort members
|
||||
@ -37,6 +39,7 @@ Feature: Add cohorts of users
|
||||
And the "Current users" select box should contain "Second User (second@example.com)"
|
||||
And the "Current users" select box should not contain "Forth User (forth@example.com)"
|
||||
|
||||
@javascript
|
||||
Scenario: Add users to a cohort using a bulk user action
|
||||
When I follow "Accounts"
|
||||
And I follow "Bulk user actions"
|
||||
|
@ -111,7 +111,7 @@ class core_course_deletecategory_form extends moodleform {
|
||||
}
|
||||
|
||||
if ($displaylist) {
|
||||
$mform->addElement('select', 'newparent', get_string('movecategorycontentto'), $displaylist);
|
||||
$mform->addElement('autocomplete', 'newparent', get_string('movecategorycontentto'), $displaylist);
|
||||
if (in_array($this->coursecat->parent, $displaylist)) {
|
||||
$mform->setDefault('newparent', $this->coursecat->parent);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class core_course_editcategory_form extends moodleform {
|
||||
$strsubmit = get_string('createcategory');
|
||||
}
|
||||
|
||||
$mform->addElement('select', 'parent', get_string('parentcategory'), $options);
|
||||
$mform->addElement('autocomplete', 'parent', get_string('parentcategory'), $options);
|
||||
|
||||
$mform->addElement('text', 'name', get_string('categoryname'), array('size' => '30'));
|
||||
$mform->addRule('name', get_string('required'), 'required', null);
|
||||
|
@ -77,7 +77,7 @@ class course_edit_form extends moodleform {
|
||||
if (empty($course->id)) {
|
||||
if (has_capability('moodle/course:create', $categorycontext)) {
|
||||
$displaylist = core_course_category::make_categories_list('moodle/course:create');
|
||||
$mform->addElement('select', 'category', get_string('coursecategory'), $displaylist);
|
||||
$mform->addElement('autocomplete', 'category', get_string('coursecategory'), $displaylist);
|
||||
$mform->addHelpButton('category', 'coursecategory');
|
||||
$mform->setDefault('category', $category->id);
|
||||
} else {
|
||||
@ -93,7 +93,7 @@ class course_edit_form extends moodleform {
|
||||
$displaylist[$course->category] = core_course_category::get($course->category, MUST_EXIST, true)
|
||||
->get_formatted_name();
|
||||
}
|
||||
$mform->addElement('select', 'category', get_string('coursecategory'), $displaylist);
|
||||
$mform->addElement('autocomplete', 'category', get_string('coursecategory'), $displaylist);
|
||||
$mform->addHelpButton('category', 'coursecategory');
|
||||
} else {
|
||||
//keep current
|
||||
|
@ -70,7 +70,7 @@ class course_request_form extends moodleform {
|
||||
|
||||
if (empty($CFG->lockrequestcategory)) {
|
||||
$displaylist = core_course_category::make_categories_list('moodle/course:request');
|
||||
$mform->addElement('select', 'category', get_string('coursecategory'), $displaylist);
|
||||
$mform->addElement('autocomplete', 'category', get_string('coursecategory'), $displaylist);
|
||||
$mform->setDefault('category', $CFG->defaultrequestcategory);
|
||||
$mform->addHelpButton('category', 'coursecategory');
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ Feature: Test category management actions
|
||||
And I should see "Category 1 (edited)" in the "#category-listing" "css_element"
|
||||
And I should see "Category 1 (edited)" in the "#course-listing h3" "css_element"
|
||||
|
||||
@javascript
|
||||
Scenario: Test deleting a categories through the management interface.
|
||||
Given the following "categories" exist:
|
||||
| name | category | idnumber |
|
||||
@ -227,9 +228,9 @@ Feature: Test category management actions
|
||||
And I should see "Delete category: Cat 1"
|
||||
And I should see "Contents of Cat 1"
|
||||
And "What to do" "select" should exist
|
||||
And "Move into" "select" should exist
|
||||
And the "Move into" select box should not contain "Cat 2"
|
||||
And the "Move into" select box should contain "Miscellaneous"
|
||||
And I expand the "Move into" autocomplete
|
||||
And "Cat 2" "autocomplete_suggestions" should not exist
|
||||
And "Miscellaneous" "autocomplete_selection" should be visible
|
||||
And I set the field "What to do" to "Delete all - cannot be undone"
|
||||
And "Move into" "select" should not be visible
|
||||
And I press "Cancel"
|
||||
|
@ -76,7 +76,7 @@ Feature: Users can request and approve courses
|
||||
And I am on course index
|
||||
And I follow "English category"
|
||||
And I press "Request a course"
|
||||
And the field "Course category" matches value "English category"
|
||||
And the "Course category" select box should contain "English category"
|
||||
And I set the following fields to these values:
|
||||
| Course full name | My new course |
|
||||
| Course short name | Mynewcourse |
|
||||
|
@ -36,7 +36,7 @@ Feature: Tagging courses
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I expand all fieldsets
|
||||
Then I should see "Mathematics" in the ".form-autocomplete-selection" "css_element"
|
||||
Then "Mathematics" "autocomplete_suggestions" should exist
|
||||
And I set the following fields to these values:
|
||||
| Tags | Algebra |
|
||||
And I press "Save and display"
|
||||
|
@ -5007,12 +5007,12 @@ class admin_settings_num_course_sections extends admin_setting_configselect {
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class admin_settings_coursecat_select extends admin_setting_configselect {
|
||||
class admin_settings_coursecat_select extends admin_setting_configselect_autocomplete {
|
||||
/**
|
||||
* Calls parent::__construct with specific arguments
|
||||
*/
|
||||
public function __construct($name, $visiblename, $description, $defaultsetting) {
|
||||
parent::__construct($name, $visiblename, $description, $defaultsetting, NULL);
|
||||
public function __construct($name, $visiblename, $description, $defaultsetting = 1) {
|
||||
parent::__construct($name, $visiblename, $description, $defaultsetting, $choices = null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -5021,8 +5021,6 @@ class admin_settings_coursecat_select extends admin_setting_configselect {
|
||||
* @return bool
|
||||
*/
|
||||
public function load_choices() {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
if (is_array($this->choices)) {
|
||||
return true;
|
||||
}
|
||||
@ -5435,6 +5433,54 @@ class admin_setting_configcheckbox_with_lock extends admin_setting_configcheckbo
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Autocomplete as you type form element.
|
||||
*
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class admin_setting_configselect_autocomplete extends admin_setting_configselect {
|
||||
/** @var boolean $tags Should we allow typing new entries to the field? */
|
||||
protected $tags = false;
|
||||
/** @var string $ajax Name of an AMD module to send/process ajax requests. */
|
||||
protected $ajax = '';
|
||||
/** @var string $placeholder Placeholder text for an empty list. */
|
||||
protected $placeholder = '';
|
||||
/** @var bool $casesensitive Whether the search has to be case-sensitive. */
|
||||
protected $casesensitive = false;
|
||||
/** @var bool $showsuggestions Show suggestions by default - but this can be turned off. */
|
||||
protected $showsuggestions = true;
|
||||
/** @var string $noselectionstring String that is shown when there are no selections. */
|
||||
protected $noselectionstring = '';
|
||||
|
||||
/**
|
||||
* Returns XHTML select field and wrapping div(s)
|
||||
*
|
||||
* @see output_select_html()
|
||||
*
|
||||
* @param string $data the option to show as selected
|
||||
* @param string $query
|
||||
* @return string XHTML field and wrapping div
|
||||
*/
|
||||
public function output_html($data, $query='') {
|
||||
global $PAGE;
|
||||
|
||||
$html = parent::output_html($data, $query);
|
||||
|
||||
if ($html === '') {
|
||||
return $html;
|
||||
}
|
||||
|
||||
$this->placeholder = get_string('search');
|
||||
|
||||
$params = array('#' . $this->get_id(), $this->tags, $this->ajax,
|
||||
$this->placeholder, $this->casesensitive, $this->showsuggestions, $this->noselectionstring);
|
||||
|
||||
// Load autocomplete wrapper for select2 library.
|
||||
$PAGE->requires->js_call_amd('core/form-autocomplete', 'enhance', $params);
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dropdown menu with an advanced checkbox, that controls a additional $name.'_adv' setting.
|
||||
|
Loading…
x
Reference in New Issue
Block a user