From 3ab9c483b596ee41e373052a1d2f4fd415f83007 Mon Sep 17 00:00:00 2001 From: Astor Bizard <astor.bizard@grenoble-inp.fr> Date: Thu, 28 Nov 2019 13:34:22 +0100 Subject: [PATCH] Added execution files and corrected files to info webservice for teachers --- externallib.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/externallib.php b/externallib.php index 443dc701..f795b324 100644 --- a/externallib.php +++ b/externallib.php @@ -68,12 +68,22 @@ class mod_vpl_webservice extends external_api { 'example' => ( int ) $instance->example, 'restrictededitor' => ( int ) $instance->restrictededitor, 'maxfiles' => ( int ) $instance->maxfiles, - 'reqfiles' => array () + 'reqfiles' => array (), + 'execfiles' => array (), + 'corrfiles' => array () ); $files = mod_vpl_edit::get_requested_files( $vpl ); // Adapt array[name]=content to format array[]=array(name,data). $files = mod_vpl_edit::files2object( $files ); $ret ['reqfiles'] = $files; + + $hasteacherrights = $vpl->has_capability( VPL_MANAGE_CAPABILITY ); + if ($hasteacherrights) { + $execfiles = $vpl->get_fgm('execution')->getAllFiles(); + $ret ['execfiles'] = mod_vpl_edit::files2object( $execfiles ); + $correctedfiles = $vpl->get_fgm('corrected')->getAllFiles(); + $ret ['corrfiles'] = mod_vpl_edit::files2object( $correctedfiles ); + } return $ret; } public static function info_returns() { @@ -89,6 +99,14 @@ class mod_vpl_webservice extends external_api { 'reqfiles' => new external_multiple_structure( new external_single_structure( array ( 'name' => new external_value( PARAM_TEXT, 'File name' ), 'data' => new external_value( PARAM_RAW, 'File content' ) + ) ) ), + 'execfiles' => new external_multiple_structure( new external_single_structure( array ( + 'name' => new external_value( PARAM_TEXT, 'File name' ), + 'data' => new external_value( PARAM_RAW, 'File content' ) + ) ) ), + 'corrfiles' => new external_multiple_structure( new external_single_structure( array ( + 'name' => new external_value( PARAM_TEXT, 'File name' ), + 'data' => new external_value( PARAM_RAW, 'File content' ) ) ) ) ) ); } @@ -128,8 +146,8 @@ class mod_vpl_webservice extends external_api { } public static function save_corrected_files_returns() { return null; - } - + } + public static function save_execution_files_parameters() { return new external_function_parameters( array ( 'id' => new external_value( PARAM_INT, 'Activity id (course_module)', VALUE_REQUIRED ), @@ -171,7 +189,7 @@ class mod_vpl_webservice extends external_api { } mod_vpl_edit::save_teacher_files( $vpl, $USER->id, $files, $type ); } - + /* * save function. save/submit the students files -- GitLab