Skip to content
Snippets Groups Projects
Commit 39e6e2b2 authored by Hamza Remmal's avatar Hamza Remmal
Browse files

draft of the get_infos function

parent 742eeb0c
Branches
Tags
No related merge requests found
...@@ -27,10 +27,12 @@ ...@@ -27,10 +27,12 @@
namespace assignsubmission_autograde\external; namespace assignsubmission_autograde\external;
use dml_exception;
use external_api; use external_api;
use external_function_parameters; use external_function_parameters;
use external_single_structure; use external_single_structure;
use external_value; use external_value;
use stdClass;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
...@@ -52,8 +54,27 @@ final class autograde_get_infos extends external_api { ...@@ -52,8 +54,27 @@ final class autograde_get_infos extends external_api {
]); ]);
} }
public static function get_infos($submissionid): object { /**
return new \stdClass(); * @throws dml_exception
*/
public static function get_infos($submissionid): string {
global $DB;
// HR : Fetch the course's and assignment's ids of the submission
$assignment_id = $DB->get_field('assign_submission', 'assignment', array('id' => $submissionid));
$course_id = $DB->get_field('assign', 'course', array('id' => $assignment_id));
// HR : Fetch the assignment's and course's metadata
$assign = $DB->get_record('assign', array('id' => $assignment_id), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $course_id), '*', MUST_EXIST);
$category = $DB->get_field('categories', 'name', array('id' => $course->category));
// HR : Build the infos object response
$infos = new stdClass();
$infos->course_short_name = $course->shortname;
$infos->course_category = $category;
return json_encode($infos);
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment