MDL-44444 Add fileurl to mod_assign_get_submissions webservice response parameters
authorJuan Leyva <juanleyvadelgado@gmail.com>
Tue, 4 Mar 2014 15:58:19 +0000 (16:58 +0100)
committerMarina Glancy <marina@moodle.com>
Tue, 18 Mar 2014 05:46:16 +0000 (13:46 +0800)
mod/assign/externallib.php

index da57052..7c12410 100644 (file)
@@ -636,8 +636,14 @@ class mod_assign_external extends external_api {
                                 false
                             );
                             foreach ($files as $file) {
-                                $filepath = array('filepath' => $file->get_filepath().$file->get_filename());
-                                $fileareainfo['files'][] = $filepath;
+                                $filepath = $file->get_filepath().$file->get_filename();
+                                $fileurl = file_encode_url($CFG->wwwroot . '/webservice/pluginfile.php', '/' . $assign->get_context()->id .
+                                    '/' . $component. '/'. $filearea . '/' . $submissionrecord->id . $filepath);
+                                $fileinfo = array(
+                                    'filepath' => $filepath,
+                                    'fileurl' => $fileurl
+                                    );
+                                $fileareainfo['files'][] = $fileinfo;
                             }
                             $plugin['fileareas'][] = $fileareainfo;
                         }
@@ -712,7 +718,9 @@ class mod_assign_external extends external_api {
                                                     'files' => new external_multiple_structure(
                                                         new external_single_structure(
                                                             array (
-                                                                'filepath' => new external_value (PARAM_TEXT, 'file path')
+                                                                'filepath' => new external_value (PARAM_TEXT, 'file path'),
+                                                                'fileurl' => new external_value (PARAM_URL, 'file download url',
+                                                                    VALUE_OPTIONAL)
                                                             )
                                                         ), 'files', VALUE_OPTIONAL
                                                     )