catalyst / moodle-mod_subcourse

Subcourse module for Moodle
https://moodle.org/plugins/mod_subcourse
GNU General Public License v3.0
24 stars 41 forks source link

Change Fetch Grades From to a search box #34

Closed mhughes2k closed 4 years ago

mhughes2k commented 5 years ago

This is the "Fetch Grades From" drop down box for our server (for me) SubCourse

Now I can see thousands of courses, but some of our staff can still see hundreds of courses, so the issue is a bit wider than me.

It would be nice if that the list of classes was known to be "unreasonable" that instead of it displaying a drop down list, it turned into a course search box (a bit like the restore backup page where you can select which course you want to back up into).

mudrd8mz commented 4 years ago

Many thanks @mhughes2k for raising this. I agree there's an usability issue here. May I ask you for trying to apply the following patch to see if that would be acceptable and useful solution for you? That change turns the default <select> into the autocompletion widget - which also brings the ability to search for the course easily.

diff --git a/mod_form.php b/mod_form.php
index 74a3eaa9ed..8ac3e5b090 100644
--- a/mod_form.php
+++ b/mod_form.php
@@ -108,7 +108,7 @@ class mod_subcourse_mod_form extends moodleform_mod {
             $includekeepref = true;
         }

-        $options = array();
+        $options = array(get_string('none'));

         if (empty($mycourses)) {
             if (empty($includekeepref)) {
@@ -127,21 +127,15 @@ class mod_subcourse_mod_form extends moodleform_mod {
                 $catlist = coursecat::make_categories_list('', 0, ' / ');
             }
             foreach ($mycourses as $mycourse) {
-                if (empty($options[$catlist[$mycourse->category]])) {
-                    $options[$catlist[$mycourse->category]] = array();
-                }
-                $courselabel = $mycourse->fullname.' ('.$mycourse->shortname.')';
-                $options[$catlist[$mycourse->category]][$mycourse->id] = $courselabel;
+                $courselabel = $catlist[$mycourse->category] . ' / ' . $mycourse->fullname.' ('.$mycourse->shortname.')';
+                $options[$mycourse->id] = $courselabel;
                 if (empty($mycourse->visible)) {
                     $hiddenlabel = ' '.get_string('hiddencourse', 'subcourse');
-                    $options[$catlist[$mycourse->category]][$mycourse->id] .= $hiddenlabel;
+                    $options[$mycourse->id] .= $hiddenlabel;
                 }
             }
-            if (!empty($includenoref)) {
-                $options['---'] = array(0 => get_string('none'));
-            }

-            $mform->addElement('selectgroups', 'refcourse', get_string('refcourselabel', 'subcourse'), $options);
+            $mform->addElement('autocomplete', 'refcourse', get_string('refcourselabel', 'subcourse'), $options);

             if (!empty($includekeepref)) {
                 $mform->disabledIf('refcourse', 'refcoursecurrent', 'checked');
mudrd8mz commented 4 years ago

Merged to master, to become available as a part of the next release.