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

New Web Services that enables editing wiki pages

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Common testing instructions

      To be done in each of the following tests:

      1. Create a course with a student. The course must have at least one section.
      2. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      3. Create a Token for the student user.
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Take note of the student token (to be used in following instructions).

      Test get page for editing

      1. Create on wiki and add a page with the following HTML code (take note of the generated pageid):

        <h1>Title1</h1>Text inside section
        <h1>Title2</h1>Text inside section
        

      2. Next, you can do a CURL REST call simulating a WS client with the student user.
        • You need to replace the wstoken, pageid and the URL of your moodle instance.

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_get_page_for_editing&pageid=1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed

      3. Confirm that you receive the same content provided to create that page.
      4. Confirm that the contentformat and version (number of edits, usually 1) is the same you provided.
      5. Now perform the request again but specifying a section to get.
        • You need to replace the wstoken, pageid and the URL of your moodle instance.

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_get_page_for_editing&pageid=1&section=Title1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed

      6. Confirm that you receive ONLY the content of the section called Title1 (including title).

      Test New page creation

      1. Create at least one group into the course and add the user to the first one.
      2. Create and individual wiki with separate groups.
      3. Next, you can do a CURL REST call simulating a WS client with the student user.
        • You need to replace the wstoken, groupid, userid, wikiid and the URL of your moodle instance.
        • Provide the desired title, content, content format you want.

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_new_page&title=Title&content=CONTENT&contentformat=html&wikiid=1&userid=1&groupid=1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed

      4. Confirm that the page has been created using the website and that the title and content corresponds to the content you provided.
      5. Get the subwikiid for the page created.
      6. Now perform the request again but without specifying the created subwikiid (userid, groupid and wikiid not needed).
      7. Next, you can do a CURL REST call simulating a WS client with the student user.
        • You need to replace the wstoken, subwikiid and the URL of your moodle instance.
        • Provide the desired title, content, content format you want.

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_new_page&title=Title2&content=CONTENT&contentformat=html&subwikiid=1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed

      8. Confirm that the page has been created using the website and that the title and content corresponds to the content you provided.

      Test Page edit

      1. Create on wiki and add a page with the following HTML code (take note of the generated pageid):

        <h1>Title1</h1>Text inside section
        <h1>Title2</h1>Text inside section
        

      2. Next, you can do a CURL REST call simulating a WS client with the student user.
        • You need to replace the wstoken, pageid and the URL of your moodle instance.
        • Provide the desired content you want.

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_edit_page&pageid=1&content=1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed

      3. Confirm that the page has been edited using the website and that the content corresponds to the content you provided.
      4. Edit the page to have the Title1 section (use the previous code).
      5. # Now perform the request again but specifying the section to be edited.
        • You need to replace the wstoken, pageid and the URL of your moodle instance.
        • Provide the desired content you want.

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_edit_page&pageid=1&section=Title1&content=1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed

      6. Confirm that only the page section has been edited using the website and that the content corresponds to the content you provided.
      Show
      Common testing instructions To be done in each of the following tests: Create a course with a student. The course must have at least one section. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the student user. Click on Site administration ► Plugins ► Web services ► Manage tokens Take note of the student token (to be used in following instructions). Test get page for editing Create on wiki and add a page with the following HTML code (take note of the generated pageid): <h1>Title1</h1>Text inside section <h1>Title2</h1>Text inside section Next, you can do a CURL REST call simulating a WS client with the student user. You need to replace the wstoken, pageid and the URL of your moodle instance. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_get_page_for_editing&pageid=1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed Confirm that you receive the same content provided to create that page. Confirm that the contentformat and version (number of edits, usually 1) is the same you provided. Now perform the request again but specifying a section to get. You need to replace the wstoken, pageid and the URL of your moodle instance. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_get_page_for_editing&pageid=1&section=Title1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed Confirm that you receive ONLY the content of the section called Title1 (including title). Test New page creation Create at least one group into the course and add the user to the first one. Create and individual wiki with separate groups. Next, you can do a CURL REST call simulating a WS client with the student user. You need to replace the wstoken, groupid, userid, wikiid and the URL of your moodle instance. Provide the desired title, content, content format you want. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_new_page&title=Title&content=CONTENT&contentformat=html&wikiid=1&userid=1&groupid=1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed Confirm that the page has been created using the website and that the title and content corresponds to the content you provided. Get the subwikiid for the page created. Now perform the request again but without specifying the created subwikiid (userid, groupid and wikiid not needed). Next, you can do a CURL REST call simulating a WS client with the student user. You need to replace the wstoken, subwikiid and the URL of your moodle instance. Provide the desired title, content, content format you want. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_new_page&title=Title2&content=CONTENT&contentformat=html&subwikiid=1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed Confirm that the page has been created using the website and that the title and content corresponds to the content you provided. Test Page edit Create on wiki and add a page with the following HTML code (take note of the generated pageid): <h1>Title1</h1>Text inside section <h1>Title2</h1>Text inside section Next, you can do a CURL REST call simulating a WS client with the student user. You need to replace the wstoken, pageid and the URL of your moodle instance. Provide the desired content you want. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_edit_page&pageid=1&content=1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed Confirm that the page has been edited using the website and that the content corresponds to the content you provided. Edit the page to have the Title1 section (use the previous code). # Now perform the request again but specifying the section to be edited. You need to replace the wstoken, pageid and the URL of your moodle instance. Provide the desired content you want. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_wiki_edit_page&pageid=1&section=Title1&content=1&wstoken=cd2be328e7db5fefa407274d1e1073a7' --compressed Confirm that only the page section has been edited using the website and that the content corresponds to the content you provided.
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull Master Branch:
      MDL-53791-master

      Description

      We need some new web services that enables the editing of wiki pages:

      • mod_wiki_get_page_for_editing: To get the raw content of the section to edit and lock the section.
      • mod_wiki_new_page: To create a page.
      • mod_wiki_edit_page: To edit a page or section in a page.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                23/May/16