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

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

XMLWordPrintable

    • MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE
    • MOODLE_30_STABLE, MOODLE_31_STABLE
    • MDL-55113-master
    • 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.

      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.

            dpalou Dani Palou
            dpalou Dani Palou
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Simey Lameze Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.