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

Return additional file fields in Web Services to be able to handle external repositories files

XMLWordPrintable

    • MOODLE_32_STABLE
    • MOODLE_33_STABLE
    • MDL-58399-master
    • Hide
      1. Add a file to Moodle (as a file resource) from an external repository (filesystem for example, or dropbox or equella or box.net)
      2. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      3. Create a Token in the mobile app service for one user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the wstoken, the course id and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_resource_get_resources_by_courses&courseids[0]=4&wstoken=12a2a65aeea2a177055e233f9e303218' --compressed | python -m "json.tool"

      5. Check that you receive the file information and the isexternalfile field is set to true and the repositorytype field is the name of the plugin of the repository you used.
      6. Now, execute the following curl request replacing the course id and the cmid with the resource file cmid:

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Origin: http://localhost:8100' --data 'courseid=4&options%5B0%5D%5Bname%5D=cmid&options%5B0%5D%5Bvalue%5D=441&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=12a2a65aeea2a177055e233f9e303218' --compressed | python -m "json.tool"

      7. Check that you receive the file information and the isexternalfile field is set to true and the repositorytype field is the name of the plugin of the repository you used.
      Show
      Add a file to Moodle (as a file resource) from an external repository (filesystem for example, or dropbox or equella or box.net) As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service 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, the course id and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=mod_resource_get_resources_by_courses&courseids [0] =4&wstoken=12a2a65aeea2a177055e233f9e303218' --compressed | python -m "json.tool" Check that you receive the file information and the isexternalfile field is set to true and the repositorytype field is the name of the plugin of the repository you used. Now, execute the following curl request replacing the course id and the cmid with the resource file cmid: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Origin: http://localhost:8100 ' --data 'courseid=4&options%5B0%5D%5Bname%5D=cmid&options%5B0%5D%5Bvalue%5D=441&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=12a2a65aeea2a177055e233f9e303218' --compressed | python -m "json.tool" Check that you receive the file information and the isexternalfile field is set to true and the repositorytype field is the name of the plugin of the repository you used.

      Now that 3.3 comes with the office integrations (google drive, office365) we should be detecting when we are treating files that are linked to external repositories.

      For doing that we'd need to return some additional fields via Web Services:

      • isexternalfile
      • mimetype (google docs files use an special one)
      • repositorytype (the repository plugin name)

            jleyva Juan Leyva
            jleyva Juan Leyva
            Ankit Agarwal Ankit Agarwal
            Andrew Lyons Andrew Lyons
            Jake Dallimore Jake Dallimore
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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