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

New Web Service mod_data_update_entry

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create in a course a database with 3 fields: checkbox (options A, B, C) being a required field, number field not required and url field not required.
      2. As a student in the course create a entry for the database with this values: checkbox A, number 6, url: https://google.com
      3. As admin enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      4. Create a Token in the mobile app service for the student in the course:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      5. Next, you can do a CURL REST call simulating a WS client with the student token.
        • You need to replace the wstoken, entry (the id of the entry you created in step2), the URL of your moodle instance and replacing data[0][fieldid]=113 with your checkbox field id (from database or inspecting the form), [fieldid]=114 with your URL field id, and [fieldid]=115 with your numeric field id.

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'entryid=19&wsfunction=mod_data_update_entry&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true&data[0][fieldid]=113&data[0][subfield]=&data[0][value]=["B","C"]&data[1][fieldid]=114&data[1][subfield]=0&data[1][value]="https:\/\/moodle.org"&data[2][fieldid]=115&data[2][subfield]=&data[2][value]="5"' | python -m "json.tool"

      6. Confirm that the existing entry is updated with values B and C for the checkbox field, 5 for the numeric, and https://moodle.org for the url one
      7. Now, if you remove &data[0][fieldid]=113&data[0][subfield]=&data[0][value]=["B","C"] from the query and execute the curl request again you should see an error indicating that the field is required
      8. If you replace all the data[x] with &data[0][fieldid]=0&data[0][subfield]=&data[0][value]= you should get a ""You did not fill out any fields!"
      9. Optionally you can check additional things like setting a read only period or trying to update other users entries in those cases the WS return errors
      10. If you want to play with other fields please review the unit tests in the patch where you will se the format for other field types
      Show
      Create in a course a database with 3 fields: checkbox (options A, B, C) being a required field, number field not required and url field not required. As a student in the course create a entry for the database with this values: checkbox A, number 6, url: https://google.com As admin 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 token. You need to replace the wstoken, entry (the id of the entry you created in step2), the URL of your moodle instance and replacing data [0] [fieldid] =113 with your checkbox field id (from database or inspecting the form), [fieldid] =114 with your URL field id, and [fieldid] =115 with your numeric field id. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'entryid=19&wsfunction=mod_data_update_entry&wstoken=12a2a65aeea2a177055e233f9e303218&moodlewssettingfilter=true&data [0] [fieldid] =113&data [0] [subfield] =&data [0] [value] = ["B","C"] &data [1] [fieldid] =114&data [1] [subfield] =0&data [1] [value] ="https:\/\/moodle.org"&data [2] [fieldid] =115&data [2] [subfield] =&data [2] [value] ="5"' | python -m "json.tool" Confirm that the existing entry is updated with values B and C for the checkbox field, 5 for the numeric, and https://moodle.org for the url one Now, if you remove &data [0] [fieldid] =113&data [0] [subfield] =&data [0] [value] = ["B","C"] from the query and execute the curl request again you should see an error indicating that the field is required If you replace all the data [x] with &data [0] [fieldid] =0&data [0] [subfield] =&data [0] [value] = you should get a ""You did not fill out any fields!" Optionally you can check additional things like setting a read only period or trying to update other users entries in those cases the WS return errors If you want to play with other fields please review the unit tests in the patch where you will se the format for other field types
    • Affected Branches:
      MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-57924-master

      Description

      Updates an existing entry

        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, Jake Dallimore, Jun Pataleta
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

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