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

New Web Services for global search

    XMLWordPrintable

Details

    • MOODLE_31_STABLE
    • MOODLE_403_STABLE
    • MDL-56020-master
    • Hide
      1. As an admin, enable “Web services for mobile devices” on Site administration ► Advanced features
      2. Go to Site Admin > Plugins > Manage global search > Display results in separate categories, ensure the setting is disabled
      3. Go to Site Admin > Plugins > Manage global search > Manage global search, set "Maximum top results" to 3
      4. Go to Developer options > Make test course and create a size "S" course
      5. Enrol one user as student in that course
      6. Go to Site administration > General > Advanced features > Enable "Global Search"
      7. Go to Site administration > Plugins > Manage global search
      8. Select "Simple search" as Search Engine
      9. Enable "Display results in separate categories"
      10. In the "Index" section, do an initial indexation of the contents
      11. In the Site home, top right you will see the search box, search for "page" and confirm that:
        • In the results you see at least 5 pages with more than 40 results of the search
      12. Create a Token in the mobile app service for the user created in step 3
        • Click on Site administration ► Server ► Web services ► Manage tokens
      13. Open the console and execute this new curl request, replacing WS_TOKEN with the token you just created and the SITE_URL with yours.

        curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_search_get_results&wstoken=WS_TOKEN&query=page' | python -m "json.tool" 

      1. Confirm that:
        • In the curl request response, you see the same results that you saw in the web (look for title tag to compare) - i.e. first page results
      2. Execute the same request but appending &page=1 after query=page
      3. Confirm that:
        • In the curl request response, you see the same results that you saw in the web for the second page (in web will say 2) and the total number of records returned matches
      4. Execute now this request:

        curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_search_view_results&wstoken=WS_TOKEN&query=page' | python -m "json.tool" 

      1. Login as admin on the site, go to Site administration > Reports -> Logs -> Get these logs and confirm that
        • You see an entry with this text "The user with id 'x' viewed page 'y' of 'page' search results" with the origin column set to "ws"
      2. Execute this curl request:

        curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_search_get_search_areas_list&wstoken=WS_TOKEN' | python -m "json.tool" 

      1. Confirm that:
        • You receive a list of search areas that matches the ones displayed in the advanced search form (the page you see after performing any global search) > Filter section >Search area dropdown
          Look for name tag in request result to compare
      2. Execute the following curl request

        curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_search_get_top_results&wstoken=WS_TOKEN&query=page' | python -m "json.tool" 

      1. Confirm that:
        • You receive only three search results that match the ones displayed in the "Top results" section in the global search web version for the same search ("page")
      Show
      As an admin, enable “Web services for mobile devices” on Site administration ► Advanced features Go to Site Admin > Plugins > Manage global search > Display results in separate categories, ensure the setting is disabled Go to Site Admin > Plugins > Manage global search > Manage global search, set "Maximum top results" to 3 Go to Developer options > Make test course and create a size "S" course Enrol one user as student in that course Go to Site administration > General > Advanced features > Enable "Global Search" Go to Site administration > Plugins > Manage global search Select "Simple search" as Search Engine Enable "Display results in separate categories" In the "Index" section, do an initial indexation of the contents In the Site home, top right you will see the search box, search for "page" and confirm that: In the results you see at least 5 pages with more than 40 results of the search Create a Token in the mobile app service for the user created in step 3 Click on Site administration ► Server ► Web services ► Manage tokens Open the console and execute this new curl request, replacing WS_TOKEN with the token you just created and the SITE_URL with yours. curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_search_get_results&wstoken=WS_TOKEN&query=page' | python -m "json.tool" Confirm that: In the curl request response, you see the same results that you saw in the web (look for title tag to compare) - i.e. first page results Execute the same request but appending &page=1 after query=page Confirm that: In the curl request response, you see the same results that you saw in the web for the second page (in web will say 2) and the total number of records returned matches Execute now this request: curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_search_view_results&wstoken=WS_TOKEN&query=page' | python -m "json.tool" Login as admin on the site, go to Site administration > Reports -> Logs -> Get these logs and confirm that You see an entry with this text "The user with id 'x' viewed page 'y' of 'page' search results" with the origin column set to "ws" Execute this curl request: curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_search_get_search_areas_list&wstoken=WS_TOKEN' | python -m "json.tool" Confirm that: You receive a list of search areas that matches the ones displayed in the advanced search form (the page you see after performing any global search) > Filter section >Search area dropdown Look for name tag in request result to compare Execute the following curl request curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_search_get_top_results&wstoken=WS_TOKEN&query=page' | python -m "json.tool" Confirm that: You receive only three search results that match the ones displayed in the "Top results" section in the global search web version for the same search ("page")

    Description

      Following webservices are introduced:

      • core_search_get_search_areas_list -Return a list of searchable areas
      • core_search_view_results - To trigger events, trigger_search_results_viewed
      • core_search_get_top_results - Get top search results.
      • core_search_get_results - Get search results.

       

      Attachments

        Issue Links

          Activity

            People

              jleyva Juan Leyva
              jleyva Juan Leyva
              Rodrigo Mady Rodrigo Mady
              Huong Nguyen Huong Nguyen
              Ron Carl Alfon Yu Ron Carl Alfon Yu
              Votes:
              2 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week, 1 day, 5 hours, 29 minutes
                  1w 1d 5h 29m

                  Clockify

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