apluslms / a-plus

A+ frontend portal - A+ LMS documentation:
https://apluslms.github.io/
Other
67 stars 72 forks source link

The module search under Add Deadline Deviations is case sensitive #1280

Closed jsorva closed 9 months ago

jsorva commented 11 months ago

A minor usability issue:

When adding deadline deviations, I don’t suppose there is any reason for the Module selection to be case sensitive.

In the pic below, I’m trying to locate a module named "Week 4" but "week" doesn’t find it.

image

markkuriekkinen commented 11 months ago

It is case-sensitive because it searches from a hidden <select> element that lists all the possible alternatives. The list is rendered already in the backend to the HTML document. On the other hand, the user search sends HTTP requests to the REST API so it is case-insensitive because the API supports case-insensitive search. (This is a technical "reason"; of course, it is not the intentional behavior that modules require correct case to match anything.)

The source of the problem is that jQuery :contains() selector is case-sensitive.

https://api.jquery.com/contains-selector/

The A+ code that implements the search: https://github.com/apluslms/a-plus/blob/46dba4057a3a0e8e4e9cebbc3369b3a37c4122d2/assets/js/ajax_search_select.js#L304

The best workaround might be to add a new jQuery selector that ignores the case. Web searches reveal a lot of examples. The A+ search-select widget would then use the new case-insensitive icontains selector. https://stackoverflow.com/a/8747204 https://gist.github.com/jakebresnehan/2288330