Allows adding multiple instances of the meta enrol plugin at once.
I had to add support to the autocomplete element for filling the field from behat
when it was not using tags. I also had to make the shortnames more easily searchable
and unique in the behat feature file.
Incorrect types were preventing the currently selected values from
being removed from the new values returned via ajax.
Also fix a selection bug with autocomplete+ajax+singleselect.
This is a squashed commit containing a number of changes:
This is an ajax driven course selector that has searching etc. It can select single, or multiple courses.
Make course selector accept a list of courses to exclude
courseselector - lookup coursename on setValue
Use the get_course_display_name_in_list function to generate the course names
Add a throttle to auto-complete to reduce spamming the server
Do a single query to fetch all the courses in the mform element when validation fails
Fix core course search function to return results when there are less than 2 chars in the query.
Handle setData with an empty array in new course selector
jQuery ajax requests containing multiple '?' get replaced with a
string similar to jQuery152330039032_1231231, this is because it
is processing a stringified data object as jsonp and thinks its a url.
workaround is to add contenttype
see https://github.com/jquery/jquery/issues/1799
This is required for when helpers include json-encoded variables as arguments.
As an example, imagine a template with content:
{{# str }} somekey, someidentifier, { "fullname": "{{ fullname }}" } {{/ str }}
If the fullname variable were to include the double-quote character (e.g.
John "Trevor" Doe) because of the way in which mustache renders content, it
would become:
{{# str }} somekey, someidentifier, { "fullname": "John "Trevor" Doe" } {{/ str }}
This results in an invalid JSON structure.
To work around this issue, the quote characters in the passed variable
must be escaped:
{{# str }} somekey, someidentifier, { "fullname": "John \"Trevor\" Doe" } {{/ str }}
Unfortunately, Mustache provides no way of doing so natively.
With this function, we can quote the text as appropriate:
{{# str }} somekey, someidentifier, { "fullname": {{# quote }}{{ fullname }}{{/ quote }} } {{/ str }}
This also handles the case where the quoted content includes the Mustache
delimeter ({{ or }}).
For example:
fullname = 'John "}}Trevor{{" Doe'
Ordinarily this would be rendered as:
{{# str }} somekey, someidentifier, { "fullname": "John "}}Trevor{{" Doe" } {{/ str }}
This rendering is both a JSON error, and also a mustache syntax error because of the mustache delimeters.
The quote helper also escapes these by wrapping them in change delimeter
tags:
{{# str }} somekey, someidentifier, { "fullname": "John "{{=<% %>=}}}}<%={{ }}=%>Trevor{{=<% %>=}}{{{{=<% %>=}}" Doe" } {{/ str }}
Introducing both APIs in moodle along with:
- search_box widget to add a tiny search box
- admin settings with setup steps helper
- cache for search results
- template for a search result
- php unit stuff
Many thanks to Tomasz Muras, Prateek Sachan and Daniel Neis for their contributions, for starting this development
and for pushing for it to be completed. Also thanks to other contributors: Jonathan Harker and eugeneventer.
Also:
* In behat, ensure nav node exists before checking attribute (Credit to
Rajesh Taneja)
* Remove some unused JS constants
* Fix debugging notice for users without settings block
In some cases, underscores in lang codes get replaced with dashes
which causes some JavaScript to be unhappy. This patch simply reverse
the underscore to dash replacement on the JS side.
Quickly navigating via the keyboard to an autocomplete
element and hitting down would result in the selections
being displayed and then quickly removed. This has now
been fixed.
Fixes 3 problems with deselecting items in an autocomplete field:
1. Keep track of whether items were in the offical suggestion list, or are newly created
tags and remove the "newly created tags" from the suggestion list when they are
deselected
2. Change the aria-role for the selected items list when items cannot be deselected (and
do not treat it like a multiselect list).
3. When leaving and returning focus to the selected items list, remember the last
active-descendant.