Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-61028

core_search: Allow filtering search by user

XMLWordPrintable

    • MOODLE_35_STABLE
    • MOODLE_35_STABLE
    • MDL-61028-master
    • Hide
      1. You will need a Moodle system that has working Moodle global search installed, using Apache Solr.
      2. Check the showuseridentity option in your admin settings. For this test it should be set to the default option, which is to show user email.
      3. Create 2 test accounts (or use existing ones). I created Amanda A (firstname Amanda, lastname A), with email address studenta@example.org and Amy B with email studentb@example.org. (Alphabetical order matters, so if you use different names, make sure the A account has a surname earlier in the alphabet than the B account.)
      4. Create 2 courses (or use existing ones). I'll be referring to these as Course A and Course B. In each course, enrol the corresponding student.
      5. In each course, create a forum, and in each forum, create a discussion (still as admin), including the word squoobot.
      6. Log in as each of the two students. For each, go to their course and to the forum in that course, and create another discussion (as the student) that also includes the word squoobot.
      7. Back as admin, update search indexing (for example by running the global search indexing task from the scheduled tasks page).
      8. Go to Course B, and then use the header to search for squoobot.
        • EXPECTED: You should see all four discussions in the results.
      9. Expand the Filter fieldset and start typing Am into the Users field.
        • EXPECTED: You should see a popup with Amanda A and Amy B included (in that alphabetical order).
      10. Select Amanda A and repeat the search.
        • EXPECTED: You should now see only the one discussion (created by Amanda A).
      11. Now set the Search within field to show only results within the course.
      12. In the Users field, delete Amanda A, then start typing Am.
        • EXPECTED: You should see a popup with Amy B and Amanda A. (It is showing users within the selected course first.)
      13. Select both Amy B and Amanda A and repeat the search.
        • EXPECTED: It now shows only Amy B's forum discussion (because that is the one by one of those two users within course B).
      14. In the Users field, delete the two existing users. Now start typing studentb@.
        • EXPECTED: It should show Amy B again, because the email matches. (Admin users are allowed to search by identity fields as well as by name.)
      15. Log in as the first test user Amanda A and try a global search for squoobot
      16. Expand the Filter fieldset and start typing Am into the Users field.
        • EXPECTED: You should only see Amanda A in the popup and not Amy B (because B is not enrolled in any of the courses where A has the moodle/user:viewdetails capability).
      17. Select Amanda and repeat the search.
        • EXPECTED: You see only the post by Amanda.
      18. Delete Amanda from the Users field and start typing studenta@
        • EXPECTED: You do not see any user results to select, because students do not have permission to search by identity fields such as email address.
      Show
      You will need a Moodle system that has working Moodle global search installed, using Apache Solr. Check the showuseridentity option in your admin settings. For this test it should be set to the default option, which is to show user email. Create 2 test accounts (or use existing ones). I created Amanda A (firstname Amanda, lastname A), with email address studenta@example.org and Amy B with email studentb@example.org . (Alphabetical order matters, so if you use different names, make sure the A account has a surname earlier in the alphabet than the B account.) Create 2 courses (or use existing ones). I'll be referring to these as Course A and Course B . In each course, enrol the corresponding student. In each course, create a forum, and in each forum, create a discussion (still as admin), including the word squoobot . Log in as each of the two students. For each, go to their course and to the forum in that course, and create another discussion (as the student) that also includes the word squoobot . Back as admin, update search indexing (for example by running the global search indexing task from the scheduled tasks page). Go to Course B , and then use the header to search for squoobot . EXPECTED: You should see all four discussions in the results. Expand the Filter fieldset and start typing Am into the Users field. EXPECTED: You should see a popup with Amanda A and Amy B included (in that alphabetical order). Select Amanda A and repeat the search. EXPECTED: You should now see only the one discussion (created by Amanda A). Now set the Search within field to show only results within the course. In the Users field, delete Amanda A, then start typing Am . EXPECTED: You should see a popup with Amy B and Amanda A. (It is showing users within the selected course first.) Select both Amy B and Amanda A and repeat the search. EXPECTED: It now shows only Amy B's forum discussion (because that is the one by one of those two users within course B). In the Users field, delete the two existing users. Now start typing studentb@ . EXPECTED: It should show Amy B again, because the email matches. (Admin users are allowed to search by identity fields as well as by name.) Log in as the first test user Amanda A and try a global search for squoobot Expand the Filter fieldset and start typing Am into the Users field. EXPECTED: You should only see Amanda A in the popup and not Amy B (because B is not enrolled in any of the courses where A has the moodle/user:viewdetails capability). Select Amanda and repeat the search. EXPECTED: You see only the post by Amanda. Delete Amanda from the Users field and start typing studenta@ EXPECTED: You do not see any user results to select, because students do not have permission to search by identity fields such as email address.

      The global search API does not permit filtering searches by user id, even though this information is already present in the schema.

      This type of search is most useful in collaborative tools, for example if you are trying to find a particular forum post that was written by your tutor and mentioned Marx, but you can't remember which discussion it was in, and you don't want to wade through all the rubbish posted by other students. (Not that it will matter when the revolution comes.)

      I propose adding suitable back-end analagous to other search filtering, and a 'User' field (or possibly 'Users', whichever is easier to implement) in the Filter area of the UI.

      Detailed description

      Selecting users

      Users are selected in a Moodle autocomplete field, so you type in some of the name and it will show a list of options. (This is consistent with existing course and search area fields.)

      The search works based on initial letters of a user's first name, last name, or full name. For example, you can find Ford Prefect by seaching for 'For', 'Pref', or 'Ford P', but not by searching 'ord'.

      For users with the moodle/site:viewuseridentity permission, you can also search on the identity fields selected in admin settings (by default email). These aren't displayed, but you can search on them. (This is probably most useful in large sites where e.g. idnumber is set to a student's ID number, and administrators want to be able to search for a specific student ID exactly.)

      Admin users, and anyone with moodle/user:viewdetails at system level, can search all users. Other users can search only users who are enrolled in courses where the current user has moodle/user:viewdetails capability. By default, this means students can only search the names of other students in the same course as them.

      Results of the search are shown in normal sort order (as per other such lists of users), which is usually alphabetical by surname, except that if you type an exact match for one of the identity fields then that user will show first. However there is one exception to this standard sort order; if you have chosen a course (or activity within a course) from the Search within dropdown, then users from that course will show first in the list.

      The list shows a maximum of 30 users.

      Searching

      The search feature is straightforward (it will only return results where the userid matches one of the selected users).

      One thing to bear in mind is that the userid schema field, on which this depends, is not implemented in all search areas. For example, both forum and glossary implement it as you would expect, but in the case of a wiki page, where the page may have been created by lots of people, there is no userid data. (The userid field accepts only one value.) 

            quen Sam Marshall
            quen Sam Marshall
            Tim Hunt Tim Hunt
            David Monllaó David Monllaó
            David Monllaó David Monllaó
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.