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

New Web Service mod_data_search_entries

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create a course with a database using the image gallery preset
      2. Enrol a couple of users as teacher and student in that course
      3. As the student or teacher add a couple of entries to the database
      4. Enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      5. Create a Token in the mobile app service for the student in the course:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Next, you can do a CURL REST call simulating a WS client with the student.
        • You need to replace the wstoken, databaseid (database instance id), search with a key word you want to search and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'databaseid=8&wsfunction=mod_data_search_entries&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true&search=searchtexthere&returncontents=1' | python -m "json.tool"

      7. Now check that you receive the entries that matches the text you searched for (you can do the same search in Moodle web version an check that the returned entries are the same)
      8. You should also check that in the listviewcontents field you see HTML output with the entries rendered (as they are rendered in the Moodle web version) except for the template header and footer.
      9. Now, remove the search parameter and add the following: &advsearch[0][name]=fn&advsearch[0][value]="juan" (replacing juan with the firstname of the users who created at least one entry)
      10. Check that you receive the list of entries created by the specified user
      11. And finally, instead searching by name do the following: &advsearch[0][name]=f_ID&advsearch[0][value]="text" where: in f_ID the ID should be replace by the field id on where you are going to search and text with the text you want to search in taht field. For example, if you have a text field with id 30 and there is an entry with the word "car" in that field you will have to use: &advsearch[0][name]=f_30&advsearch[0][value]="car"
      12. Execute the curl request and check that you receive the entries matching the text in the field.
      Show
      Create a course with a database using the image gallery preset Enrol a couple of users as teacher and student in that course As the student or teacher add a couple of entries to the database Enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for the student in the course: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the student. You need to replace the wstoken, databaseid (database instance id), search with a key word you want to search and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'databaseid=8&wsfunction=mod_data_search_entries&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true&search=searchtexthere&returncontents=1' | python -m "json.tool" Now check that you receive the entries that matches the text you searched for (you can do the same search in Moodle web version an check that the returned entries are the same) You should also check that in the listviewcontents field you see HTML output with the entries rendered (as they are rendered in the Moodle web version) except for the template header and footer. Now, remove the search parameter and add the following: &advsearch [0] [name] =fn&advsearch [0] [value] ="juan" (replacing juan with the firstname of the users who created at least one entry) Check that you receive the list of entries created by the specified user And finally, instead searching by name do the following: &advsearch [0] [name] =f_ID&advsearch [0] [value] ="text" where: in f_ID the ID should be replace by the field id on where you are going to search and text with the text you want to search in taht field. For example, if you have a text field with id 30 and there is an entry with the word "car" in that field you will have to use: &advsearch [0] [name] =f_30&advsearch [0] [value] ="car" Execute the curl request and check that you receive the entries matching the text in the field.
    • Affected Branches:
      MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-57920-master

      Description

      Search entries and return the entries found and the list representation for the given search and page.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Pau Ferrer
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              Eloy Lafuente (stronk7)
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/May/17