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

Global search: Make it possible to search blocks

    Details

    • Testing Instructions:
      Hide

      0 You will need a site that is configured for global search with an Apache Solr instance configured and working.

      1 Add the following HTML blocks, all of which should have text including the word 'flooglewhatsit' unless otherwise specified. To make testing easier, I suggest using the titles 'Block A', 'Block B', etc.

      a. On the site homepage
      b. On a course home page (referred to as Course 1)
      c. Second block on Course 1 home page
      d. Third block on Course 1 home page, but without any content (i.e. just add it and leave blank)
      e. On a different course home page (referred to as Course 2). For this one, change the setting 'Display on page type' to 'Any page'.
      f. On a Page activity within Course 2

      2  Ensure that the HTML block content search area is enabled, and ensure that search indexing has run (this may happen automatically on cron, or you can run it using 'Run now' on the global search indexing task on the scheduled tasks page)

      3 Enrol one test student account Student A on Course 1 and Course 2

      4 Enrol another test student account Student B on Course 2 only

      5 As admin, do a global search for flooglewhatsit.

      EXPECTED: Results should include the blocks a, b, c, and e. (This is because only blocks on course/site home pages - not on the Page activity - are indexed, and also the blank block is not indexed.)

      6 Follow the links from the search result to each block.

      EXPECTED: The main link and 'in context' link should go to the same place, which is the site home for block a and the course homepage for blocks b, c, and e, with an anchor that jumps you down to the block if visible. The course link should go to the course/site home page without the anchor.

      7 Log in as Student A and repeat the search.

      EXPECTED: Results should be the same (blocks a, b, c, and e).

      8 Repeat the search, but use the Filter option to include only course 1.

      EXPECTED: Results should now include only b and c (not a which is on the site course, or e which is on course 2).

      9 Log in as Student B and repeat the search

      EXPECTED: Results should include only blocks a and e.

      10 Log back in as admin and go to course 1; turn editing on.

      11 Set block b to hidden.

      12 For block c, override permissions to remove both 'Student' and Authenticated user' roles from having moodle/block:view capability. (This will cause the block to disappear when a student is logged in.)

      13 Log in as student B and repeat the search

      EXPECTED: Results should now include only blocks a and  e.

      14 Log back in as admin and go to the Page activity inside course 2 (where blocks e and f both appear). Turn editing on.

      15. Edit settings for block e and change the 'Where this block appears' option to 'Any page module page'.

      16. Repeat the search as admin

      EXPECTED: Results should now include only blocks a, b, and c (not e).

      17. Edit block e settings again and change it to 'Any page'.

      18. Repeat the search as admin

      EXPECTED: It still only shows a, b, and c (because block 'e' got removed from the index when its page type didn't match any more)

      19. Run the scheduled task to update the index, and then repeat the search another time

      EXPECTED: It should now show a, b, c, and e again.

      Backup and restore testing

      The backup code for blocks was changed slightly; this just tests it didn't break.

      20 Back up the course

      21 Restore it as a new course

      EXPECTED: The restore should complete without error.

      22 On another Moodle system that has not yet had this code applied, find (or create) a course that contains at least one HTML block.

      23. Back up the course.

      24. Restore the course on the site being tested.

      EXPECTED: The restore should complete without error. (This is testing that backup works even if time is not specified.)

      NOTE: Because backup and restore works correctly to restore the modified time, restored sites might not show up in the search index (i.e. if you restore an old block with modified time in the past, and the search system has already indexed past that time, then the block never gets indexed). This is a fun problem with the global search system in general which affects almost all other searched items, so I think fixing it is out of scope for this issue!

      Show
      0 You will need a site that is configured for global search with an Apache Solr instance configured and working. 1 Add the following HTML blocks, all of which should have text including the word 'flooglewhatsit' unless otherwise specified. To make testing easier, I suggest using the titles 'Block A', 'Block B', etc. a. On the site homepage b. On a course home page (referred to as Course 1) c. Second block on Course 1 home page d. Third block on Course 1 home page, but without any content (i.e. just add it and leave blank) e. On a different course home page (referred to as Course 2). For this one, change the setting 'Display on page type' to 'Any page'. f. On a Page activity within Course 2 2  Ensure that the HTML block content search area is enabled, and ensure that search indexing has run (this may happen automatically on cron, or you can run it using 'Run now' on the global search indexing task on the scheduled tasks page) 3 Enrol one test student account Student A on Course 1 and Course 2 4 Enrol another test student account Student B on Course 2 only 5 As admin, do a global search for flooglewhatsit. EXPECTED: Results should include the blocks a, b, c, and e. (This is because only blocks on course/site home pages - not on the Page activity - are indexed, and also the blank block is not indexed.) 6 Follow the links from the search result to each block. EXPECTED: The main link and 'in context' link should go to the same place, which is the site home for block a and the course homepage for blocks b, c, and e, with an anchor that jumps you down to the block if visible. The course link should go to the course/site home page without the anchor. 7 Log in as Student A and repeat the search. EXPECTED: Results should be the same (blocks a, b, c, and e). 8 Repeat the search, but use the Filter option to include only course 1. EXPECTED: Results should now include only b and c (not a which is on the site course, or e which is on course 2). 9 Log in as Student B and repeat the search EXPECTED: Results should include only blocks a and e. 10 Log back in as admin and go to course 1; turn editing on. 11 Set block b to hidden. 12 For block c, override permissions to remove both 'Student' and Authenticated user' roles from having moodle/block:view capability. (This will cause the block to disappear when a student is logged in.) 13 Log in as student B and repeat the search EXPECTED: Results should now include only blocks a and  e. 14 Log back in as admin and go to the Page activity inside course 2 (where blocks e and f both appear). Turn editing on. 15. Edit settings for block e and change the 'Where this block appears' option to 'Any page module page'. 16. Repeat the search as admin EXPECTED: Results should now include only blocks a, b, and c (not e). 17. Edit block e settings again and change it to 'Any page'. 18. Repeat the search as admin EXPECTED: It still only shows a, b, and c (because block 'e' got removed from the index when its page type didn't match any more) 19. Run the scheduled task to update the index, and then repeat the search another time EXPECTED: It should now show a, b, c, and e again. Backup and restore testing The backup code for blocks was changed slightly; this just tests it didn't break. 20 Back up the course 21 Restore it as a new course EXPECTED: The restore should complete without error. 22 On another Moodle system that has not yet had this code applied, find (or create) a course that contains at least one HTML block. 23. Back up the course. 24. Restore the course on the site being tested. EXPECTED: The restore should complete without error. (This is testing that backup works even if time is not specified.) NOTE: Because backup and restore works correctly to restore the modified time, restored sites might not show up in the search index (i.e. if you restore an old block with modified time in the past, and the search system has already indexed past that time, then the block never gets indexed). This is a fun problem with the global search system in general which affects almost all other searched items, so I think fixing it is out of scope for this issue!
    • Affected Branches:
      MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_34_STABLE
    • Pull Master Branch:
      MDL-58957-master

      Description

      The global search API does not support searching of blocks. (Specifically, a block could potentially add indexed content in course context, but there is no way to add indexed content in block context, which means the search can't be aware of things like the moodle/block:view capability or the block hide/show option.)

      Most blocks are functional and do not contain content of their own (they often display content which originates in other locations), so they do not need to be searched. However, the HTML block contains content and it would be useful to be able to search within this.

      Additionally, many people implement custom code as blocks, and some of this might benefit from searching. At the OU we have a custom news block which we want to make searchable.

      Note that blocks are really complicated in this regard because they can appear in multiple places and a completely generic solution is currently impossible. However for content blocks it is probably most likely that they are added to the course page - I suggest that for an initial implementation we just support that page, and other pages can be added later.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    13/Nov/17