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

core_search: Allow search of specific context

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      You need a Moodle system with a working Moodle global search installation (e.g. Apache Solr). Also, you need to make sure your browser window is wide enough that it actually shows the ? search icon.

      1. Create a new course called Search test squigflorp
      2. Add a forum called Forum about squigflorp
      3. In the forum, add a discussion that also contains the word squigflorp.
      4. Create a second course called Search test squigflorp 2
      5. Add a forum called Forum about squigflorp 2
      6. Add a discussion with the word squigflorp.
      7. Run search indexing (e.g. by running the search indexing scheduled task using the 'Run now' option on the scheduled tasks page).
      8. Go to the Moodle dashboard page (/my/) and type squigflorp in the search ? field in the header, and hit Return.
        • EXPECTED: The search page should appear as before, showing six results (the two courses, forums, and discussions) and with no Search within option.
        • EXPECTED: If you expand the Filter fieldset, you should see there is no Search within option, but there is a Courses option where you can choose a specific course.
      9. Go to the second course page and type squigflorp in the search ? field in the header, and hit Return.
        • EXPECTED: You should see the same 6 results.
        • EXPECTED: This time there is a Search within dropdown just below the search box.
        • EXPECTED: There should be two options in the dropdown, Everywhere you can access (selected) and Course: Search test squigflorp 2.
      10. Expand the Filter fieldset.
        • EXPECTED: You should still see the Courses option.
      11. # Change the Search within dropdown to select the course.
        • EXPECTED: The Courses option, below, disappears as no longer relevant.
      12. Hit the button to search again.
        • EXPECTED: There should now be only 3 results (all the results from the second course).
      13. Go into either of the forums, and repeat the same search from the header on this screen.
        • EXPECTED: You should see all 6 results with a Search within dropdown.
        • EXPECTED: There should now be 3 options in the dropdown; you can choose to search just the forum.
      14. Change the dropdown to select only the forum and use the button to repeat the search.
        • EXPECTED: There are now only 2 results (the forum itself and the discussion within it, but not the course page).
      15. Go to one of the courses, and turn editing on if necessary.
      16. Choose 'Add a block' and 'Global search'.
      17. Type in sqigflorp into the global search block that now appears.
      18. On the search screen, expand Filters
        • EXPECTED: The Search within dropdown appears, and shows the correct course name.
      Show
      You need a Moodle system with a working Moodle global search installation (e.g. Apache Solr). Also, you need to make sure your browser window is wide enough that it actually shows the ? search icon. Create a new course called Search test squigflorp Add a forum called Forum about squigflorp In the forum, add a discussion that also contains the word squigflorp . Create a second course called Search test squigflorp 2 Add a forum called Forum about squigflorp 2 Add a discussion with the word squigflorp . Run search indexing (e.g. by running the search indexing scheduled task using the 'Run now' option on the scheduled tasks page). Go to the Moodle dashboard page (/my/) and type squigflorp in the search ? field in the header, and hit Return. EXPECTED: The search page should appear as before, showing six results (the two courses, forums, and discussions) and with no Search within option. EXPECTED: If you expand the Filter fieldset, you should see there is no Search within option, but there is a Courses option where you can choose a specific course. Go to the second course page and type squigflorp in the search ? field in the header, and hit Return. EXPECTED: You should see the same 6 results. EXPECTED: This time there is a Search within dropdown just below the search box. EXPECTED: There should be two options in the dropdown, Everywhere you can access (selected) and Course: Search test squigflorp 2 . Expand the Filter fieldset. EXPECTED: You should still see the Courses option. # Change the Search within dropdown to select the course. EXPECTED: The Courses option, below, disappears as no longer relevant. Hit the button to search again. EXPECTED: There should now be only 3 results (all the results from the second course). Go into either of the forums, and repeat the same search from the header on this screen. EXPECTED: You should see all 6 results with a Search within dropdown. EXPECTED: There should now be 3 options in the dropdown; you can choose to search just the forum. Change the dropdown to select only the forum and use the button to repeat the search. EXPECTED: There are now only 2 results (the forum itself and the discussion within it, but not the course page). Go to one of the courses, and turn editing on if necessary. Choose 'Add a block' and 'Global search'. Type in sqigflorp into the global search block that now appears. On the search screen, expand Filters EXPECTED: The Search within dropdown appears, and shows the correct course name.
    • Affected Branches:
      MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE
    • Pull Master Branch:
      MDL-60880-master

      Description

      Currently it is possible to restrict a search to specified course or courses but not to a single context, such as an activity. For example, you cannot search only within a specific forum. This is a common requirement for our users.

      I propose making it possible to also search within a single specified bottom-level context - one activity. The system would still check you can access that context as before.

      Note this feature is not intended to support a tree of subcontexts (i.e. you can't search a whole category or something this way) - only to search a specified context or contexts.

      There are two parts to this change: the back-end and the front-end UI. The back-end is relatively straightforward. (If there is any degree of controversy about this I might split into two issues so we can get the back-end committed and argue about the rest later!)

      For the front-end, I propose a simple minimal implementation for context-sensitive search (I think this was Tim's idea originally):

      • When you carry out a search from the header, the context id for the page you searched on will be passed to the search form.
      • If you search within a course, activity, or block context, then the search page will display a new Search within dropdown.
      • From the dropdown you can choose to search everything you can access (the default behaviour, as at present), or only within the current course that you came from, or only within the current block/activity that you came from.
      • If the Search within dropdown appears, then the existing Courses option that lets you select a course does not appear.

      When you search from the site level or another context, you don't get the Search within option, and you do get the ability to choose one or more courses again.

      See screenshot.

        Attachments

        1. searchwithin.png
          14 kB
          Sam Marshall
        2. searchwithin.png
          32 kB
          Sam Marshall

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  17/May/18