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

New Web Service mod_glossary_update_entry

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.2, 3.10, 4.0
    • Fix Version/s: 3.10
    • Component/s: Glossary
    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_35_STABLE, MOODLE_400_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE
    • Pull from Repository:
    • Pull 3.10 Branch:
      MDL-63805-310
    • Pull Master Branch:
      MDL-63805-master
    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a new course and enrol one user as student (student1)
      3. Create a new Glossary activity
      4. Log-in as the student1 into the course
      5. Create a new glossary entry with the following data:
        • Concept: Omelette
        • Definition: Spanish omelette
        • Keywords: potatoes onions eggs (each in one new line)
        • Attachments: Attach a pdf file or image (whatever)
      6. Copy somewhere the id of the glossary entry you created (to get the id of the entry, you can click on the cog that is displayed when browsing the entry below to the right, and from the URL copy the value of the id parameter)
      7. Log.in again as admin into the site
      8. Create a Token in the mobile app service for the student1 user in the site
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      9. Open the console an execute this new curl request, replacing wstoken with the student1 token and the site url with yours. Replace the "id" value with any of the entry values you previously copied

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_glossary_prepare_entry_for_edition&wstoken=3af67232a7596ceb658df4db329e5ad6&entryid=8' --compressed | python -m "json.tool"

      10. Confirm that:
        • In the curl request response you see an "aliases" field with the words: potatoes, onion, eggs
        • You see two areas (definition and attachment)
        • You see two fields: attachmentsid and inlineattachmentsid that are not empty and are numeric
      11. Now, create a local file called "testomelette.txt" and place it in your main documents folder
      12. Execute the following request to upload a file to a temporary folder in the server , replacing the URL and token values, YOURDOCUMENTSPATH with tthe path to the file in your computer, and the itemid value with the value of the attachmentsid field returned in the previous request

        curl -i -F name=testomelette.txt -F filedata=@YOURDOCUMENTSPATH/testomelette.txt "http://localhost/m/stable_master/webservice/upload.php?token=3af67232a7596ceb658df4db329e5ad6&filearea=draft&itemid=222098146"

      13. Confirm that:
        • the response of the previous curl request is a JSON structure that contains the file name "testomelette.txt"
      14. Now, execute the following curl request to update the entry replacing as usual the URL and wstoken values and DRAFTITEMID with the value of the attachmentsid field returned in the initial request

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_glossary_update_entry&wstoken=3af67232a7596ceb658df4db329e5ad6&entryid=8&concept=Tortilla&definition=Yummy&definitionformat=1&options[0][name]=aliases&options[0][value]=potatoes,eggs&options[1][name]=attachmentsid&options[1][value]=DRAFTITEMID' --compressed | python -m "json.tool"

      15. Confirm that:
        • the result field of the curl request response is set to true
        • in the web site, if you open again the Entry (via the cog icon) you see the following values updated:
        • Concept: Tortilla
        • Definition: Yummy
        • Keywords: potatoes eggs (each in one new line)
        • Attachments: You see two files, your original attachment and the testomelette.txt file
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a new course and enrol one user as student (student1) Create a new Glossary activity Log-in as the student1 into the course Create a new glossary entry with the following data: Concept: Omelette Definition: Spanish omelette Keywords: potatoes onions eggs (each in one new line) Attachments: Attach a pdf file or image (whatever) Copy somewhere the id of the glossary entry you created (to get the id of the entry, you can click on the cog that is displayed when browsing the entry below to the right, and from the URL copy the value of the id parameter) Log.in again as admin into the site Create a Token in the mobile app service for the student1 user in the site Click on Site administration ► Plugins ► Web services ► Manage tokens Open the console an execute this new curl request, replacing wstoken with the student1 token and the site url with yours. Replace the "id" value with any of the entry values you previously copied curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_glossary_prepare_entry_for_edition&wstoken=3af67232a7596ceb658df4db329e5ad6&entryid=8' --compressed | python -m "json.tool" Confirm that: In the curl request response you see an "aliases" field with the words: potatoes, onion, eggs You see two areas (definition and attachment) You see two fields: attachmentsid and inlineattachmentsid that are not empty and are numeric Now, create a local file called "testomelette.txt" and place it in your main documents folder Execute the following request to upload a file to a temporary folder in the server , replacing the URL and token values, YOURDOCUMENTSPATH with tthe path to the file in your computer, and the itemid value with the value of the attachmentsid field returned in the previous request curl -i -F name=testomelette.txt -F filedata=@YOURDOCUMENTSPATH/testomelette.txt "http://localhost/m/stable_master/webservice/upload.php?token=3af67232a7596ceb658df4db329e5ad6&filearea=draft&itemid=222098146" Confirm that: the response of the previous curl request is a JSON structure that contains the file name "testomelette.txt" Now, execute the following curl request to update the entry replacing as usual the URL and wstoken values and DRAFTITEMID with the value of the attachmentsid field returned in the initial request curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_glossary_update_entry&wstoken=3af67232a7596ceb658df4db329e5ad6&entryid=8&concept=Tortilla&definition=Yummy&definitionformat=1&options [0] [name] =aliases&options [0] [value] =potatoes,eggs&options [1] [name] =attachmentsid&options [1] [value] =DRAFTITEMID' --compressed | python -m "json.tool" Confirm that: the result field of the curl request response is set to true in the web site, if you open again the Entry (via the cog icon) you see the following values updated: Concept: Tortilla Definition: Yummy Keywords: potatoes eggs (each in one new line) Attachments: You see two files, your original attachment and the testomelette.txt file

      Description

      Ws for updating entries

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Dani Palou Dani Palou
              Integrator:
              Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
              Tester:
              Janelle Barcega Janelle Barcega
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Nov/20

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 1 hour, 55 minutes
                  1d 1h 55m