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

External param text for onlinetext submission plugin in assign should be PARAM_RAW

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Create a course with a student.
      2. Create an assignment accepting ONLY online text.
      3. Enable "Mobile services": Plugins ► Web Services ► Mobile
      4. Create a Token for the student:
        • 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 user.
        • You need to replace the wstoken, assignmentid and the URL of your moodle instance.
        • Request for Moodle 3.1 and master:

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'assignmentid=1&wstoken=5b6154a56566a194f60f7f395f235179&wsfunction=mod_assign_save_submission&plugindata[onlinetext_editor][text]=<p>abc</p>&plugindata[onlinetext_editor][format]=1&plugindata[onlinetext_editor][itemid]=0'

        • Request for Moodle 3.0:

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'assignmentid=1&wstoken=5b6154a56566a194f60f7f395f235179&wsfunction=mod_assign_save_submission&plugindata[onlinetext_editor][text]=<p>abc</p>&plugindata[onlinetext_editor][format]=1&plugindata[onlinetext_editor][itemid]=0&plugindata[files_filemanager]=0'

          Note, you can use jsonlint.com to validate and format the json returned string or append "| python -m json.tool" to automatically format the command output

      6. Confirm that you receive an empty array as the response. Login as the student in Moodle, go to the assignment and check that the 'abc' text has been saved.
      Show
      Create a course with a student. Create an assignment accepting ONLY online text . Enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the student: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the student user. You need to replace the wstoken, assignmentid and the URL of your moodle instance. Request for Moodle 3.1 and master: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'assignmentid=1&wstoken=5b6154a56566a194f60f7f395f235179&wsfunction=mod_assign_save_submission&plugindata [onlinetext_editor] [text] =<p>abc</p>&plugindata [onlinetext_editor] [format] =1&plugindata [onlinetext_editor] [itemid] =0' Request for Moodle 3.0: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'assignmentid=1&wstoken=5b6154a56566a194f60f7f395f235179&wsfunction=mod_assign_save_submission&plugindata [onlinetext_editor] [text] =<p>abc</p>&plugindata [onlinetext_editor] [format] =1&plugindata [onlinetext_editor] [itemid] =0&plugindata [files_filemanager] =0' Note, you can use jsonlint.com to validate and format the json returned string or append "| python -m json.tool" to automatically format the command output Confirm that you receive an empty array as the response. Login as the student in Moodle, go to the assignment and check that the 'abc' text has been saved.
    • Affected Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-55113-master

      Description

      The onlinetext plugin defines its 'text' param like this:

      'text' => new external_value(PARAM_TEXT, 'The text for this submission.'
      

      This means that the parameter does NOT accept HTML, and it should. It should be PARAM_RAW.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Jul/16