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

New Web Service mod_glossary_add_entry

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.1, 3.2
    • Fix Version/s: 3.2
    • Component/s: Glossary
    • Labels:
    • Testing Instructions:
      Hide

      This patch introduces some core changes, basically I moved some code from edit_entry.php to new functions. This means that the web interface must be tested:

      1. Create a new glossary, selct Display format (Entry list)
      2. Create glossary categories (when browsing the glossary, go to browse by category and you sill see a link to Edit categories
      3. And create new entries, testing that all the settings works correctly (categories, keywords (aliases), attachments, inline attachments etc..
      4. Check that the new entries are created correctly and that you can edit them without any issue
      5. Once you have finished, you can test the new Web Service:
      6. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      7. Create a Token for one user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      8. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the wstoken, glossary instance id with your own and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'glossaryid=1&concept=Something&definition=the_definition&wsfunction=mod_glossary_add_entry&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

          # Check that the new entry was created, it can be in the approval list if you are using a token for a student user

      9. Run again the curl command an check that you get an exception: errconceptalreadyexists
      10. Now, add a options parameter, indicating additional options like aliases and categories: &options[0][name]=categories&options[0][value]=1&options[1][name]=aliases&options[1][value]=alias1,alias2
      11. Check that the new entry is created with the alias and in the sections
      12. You can play with the rest of optional options like usedynalink casesensitive fullmatch
      13. If you want to attach files, you need to upload them to get the attachmentsid, for upload files you can do:
      14. You will get an itemid that you can use as attachmentsid
      Show
      This patch introduces some core changes, basically I moved some code from edit_entry.php to new functions. This means that the web interface must be tested: Create a new glossary, selct Display format (Entry list) Create glossary categories (when browsing the glossary, go to browse by category and you sill see a link to Edit categories And create new entries, testing that all the settings works correctly (categories, keywords (aliases), attachments, inline attachments etc.. Check that the new entries are created correctly and that you can edit them without any issue Once you have finished, you can test the new Web Service: As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for one user: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the user. You need to replace the wstoken, glossary instance id with your own and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'glossaryid=1&concept=Something&definition=the_definition&wsfunction=mod_glossary_add_entry&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" # Check that the new entry was created, it can be in the approval list if you are using a token for a student user Run again the curl command an check that you get an exception: errconceptalreadyexists Now, add a options parameter, indicating additional options like aliases and categories: &options [0] [name] =categories&options [0] [value] =1&options [1] [name] =aliases&options [1] [value] =alias1,alias2 Check that the new entry is created with the alias and in the sections You can play with the rest of optional options like usedynalink casesensitive fullmatch If you want to attach files, you need to upload them to get the attachmentsid, for upload files you can do: curl -i -F filedata=@/Users/juanleyvadelgado/Documents/fast http://localhost/m/stable_master/webservice/upload.php?token=ffbe3a3002f235bf9d01fd9369e10b66&filearea=draft " You will get an itemid that you can use as attachmentsid
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-55785-master

      Description

      Web Services for adding new entries in a glossary.

      Parameters:
      glossaryid, concept, definition, options (for all the optional settings and possible attachments)

      I'll be following the same patterns applied when mod_forum_add_post was implemented, so this type of functions are consistent

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  5/Dec/16