From bff7c36ccdbc59d59a52a584a37f98328fe0952c Mon Sep 17 00:00:00 2001 From: Lai Wei Date: Fri, 25 Oct 2024 20:49:41 +0100 Subject: [PATCH] changes in local_o365 --- .../webservices/create_onenoteassignment.php | 18 ++--- .../webservices/delete_onenoteassignment.php | 9 ++- .../webservices/exception/assignnotfound.php | 4 +- .../exception/couldnotsavegrade.php | 4 +- .../exception/invalidassignment.php | 4 +- .../webservices/exception/modulenotfound.php | 4 +- .../webservices/exception/sectionnotfound.php | 4 +- .../classes/webservices/read_assignments.php | 69 ++++++++++--------- .../classes/webservices/read_courseusers.php | 16 +++-- .../webservices/read_onenoteassignment.php | 12 ++-- .../webservices/read_teachercourses.php | 8 +-- .../o365/classes/webservices/update_grade.php | 19 ++--- .../webservices/update_onenoteassignment.php | 18 ++--- local/o365/classes/webservices/utils.php | 3 + 14 files changed, 111 insertions(+), 81 deletions(-) diff --git a/local/o365/classes/webservices/create_onenoteassignment.php b/local/o365/classes/webservices/create_onenoteassignment.php index be208dca3..9cb4111d9 100644 --- a/local/o365/classes/webservices/create_onenoteassignment.php +++ b/local/o365/classes/webservices/create_onenoteassignment.php @@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die(); +use context_course; use core_external\external_api; use core_external\external_function_parameters; use core_external\external_single_structure; @@ -34,7 +35,7 @@ global $CFG; -require_once($CFG->dirroot.'/course/modlib.php'); +require_once($CFG->dirroot . '/course/modlib.php'); /** * Create assignment API class. @@ -65,12 +66,12 @@ public static function assignment_create_parameters() { * @return array An array of parameters, if successful. */ public static function assignment_create($data) { - global $DB, $CFG; + global $CFG; $params = self::validate_parameters(self::assignment_create_parameters(), ['data' => $data]); $params = $params['data']; - $context = \context_course::instance($params['course']); + $context = context_course::instance($params['course']); self::validate_context($context); $defaults = [ @@ -97,8 +98,8 @@ public static function assignment_create($data) { 'modulename' => 'assign', 'course' => $course->id, 'section' => $params['section'], - 'visible' => (int)$params['visible'], - 'duedate' => (int)$params['duedate'], + 'visible' => (int) $params['visible'], + 'duedate' => (int) $params['duedate'], 'name' => $params['name'], 'cmidnumber' => '', 'introeditor' => ['text' => $params['intro'], 'format' => FORMAT_HTML, 'itemid' => null], @@ -108,9 +109,10 @@ public static function assignment_create($data) { ]; $modinfo = array_merge($defaults, $modinfo); - $modinfo = create_module((object)$modinfo, $course); + $modinfo = create_module((object) $modinfo, $course); + + $modinfo = utils::get_assignment_return_info($modinfo->coursemodule, $modinfo->course); - $modinfo = \local_o365\webservices\utils::get_assignment_return_info($modinfo->coursemodule, $modinfo->course); return ['data' => [$modinfo]]; } @@ -120,6 +122,6 @@ public static function assignment_create($data) { * @return external_single_structure Object describing return parameters for this webservice method. */ public static function assignment_create_returns() { - return \local_o365\webservices\utils::get_assignment_return_info_schema(); + return utils::get_assignment_return_info_schema(); } } diff --git a/local/o365/classes/webservices/delete_onenoteassignment.php b/local/o365/classes/webservices/delete_onenoteassignment.php index 3c6546b5e..b13135d43 100644 --- a/local/o365/classes/webservices/delete_onenoteassignment.php +++ b/local/o365/classes/webservices/delete_onenoteassignment.php @@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die(); +use context_course; use core_external\external_api; use core_external\external_function_parameters; use core_external\external_single_structure; @@ -34,7 +35,7 @@ global $CFG; -require_once($CFG->dirroot.'/course/modlib.php'); +require_once($CFG->dirroot . '/course/modlib.php'); /** * Delete assignment API class. @@ -66,14 +67,15 @@ public static function assignment_delete($data) { $params = self::validate_parameters(self::assignment_delete_parameters(), ['data' => $data]); $params = $params['data']; - list($course, $module, $assign) = \local_o365\webservices\utils::verify_assignment($params['coursemodule'], + [$course, $module, $assign] = utils::verify_assignment($params['coursemodule'], $params['course']); - $context = \context_course::instance($params['course']); + $context = context_course::instance($params['course']); self::validate_context($context); // Course_delete_module will throw exception if error, so we can return true b/c if we get there it was successful. course_delete_module($module->id); + return ['result' => true]; } @@ -86,6 +88,7 @@ public static function assignment_delete_returns() { $params = [ 'result' => new external_value(PARAM_BOOL, 'success/failure'), ]; + return new external_single_structure($params); } } diff --git a/local/o365/classes/webservices/exception/assignnotfound.php b/local/o365/classes/webservices/exception/assignnotfound.php index 8237e3fa1..249709ab1 100644 --- a/local/o365/classes/webservices/exception/assignnotfound.php +++ b/local/o365/classes/webservices/exception/assignnotfound.php @@ -25,10 +25,12 @@ namespace local_o365\webservices\exception; +use moodle_exception; + /** * Exception thrown when an associated assignment record is not found for a given course module. */ -class assignnotfound extends \moodle_exception { +class assignnotfound extends moodle_exception { /** * Constructor. * diff --git a/local/o365/classes/webservices/exception/couldnotsavegrade.php b/local/o365/classes/webservices/exception/couldnotsavegrade.php index 16f85c17d..268d1864b 100644 --- a/local/o365/classes/webservices/exception/couldnotsavegrade.php +++ b/local/o365/classes/webservices/exception/couldnotsavegrade.php @@ -25,10 +25,12 @@ namespace local_o365\webservices\exception; +use moodle_exception; + /** * Exception thrown when a grade could not be saved in local_o365_update_grade. */ -class couldnotsavegrade extends \moodle_exception { +class couldnotsavegrade extends moodle_exception { /** * Constructor. * diff --git a/local/o365/classes/webservices/exception/invalidassignment.php b/local/o365/classes/webservices/exception/invalidassignment.php index 83e938ef4..f62fe6cd7 100644 --- a/local/o365/classes/webservices/exception/invalidassignment.php +++ b/local/o365/classes/webservices/exception/invalidassignment.php @@ -25,10 +25,12 @@ namespace local_o365\webservices\exception; +use moodle_exception; + /** * Exception thrown when a module is called that is not a OneNote assignment. */ -class invalidassignment extends \moodle_exception { +class invalidassignment extends moodle_exception { /** * Constructor. * diff --git a/local/o365/classes/webservices/exception/modulenotfound.php b/local/o365/classes/webservices/exception/modulenotfound.php index cbe6829ca..c6361daf9 100644 --- a/local/o365/classes/webservices/exception/modulenotfound.php +++ b/local/o365/classes/webservices/exception/modulenotfound.php @@ -25,10 +25,12 @@ namespace local_o365\webservices\exception; +use moodle_exception; + /** * Exception thrown when a module that does not exist is called. */ -class modulenotfound extends \moodle_exception { +class modulenotfound extends moodle_exception { /** * Constructor. * diff --git a/local/o365/classes/webservices/exception/sectionnotfound.php b/local/o365/classes/webservices/exception/sectionnotfound.php index 10be9e256..9aeda353d 100644 --- a/local/o365/classes/webservices/exception/sectionnotfound.php +++ b/local/o365/classes/webservices/exception/sectionnotfound.php @@ -25,10 +25,12 @@ namespace local_o365\webservices\exception; +use moodle_exception; + /** * Exception thrown when a course section that does not exist is used to update an assignment. */ -class sectionnotfound extends \moodle_exception { +class sectionnotfound extends moodle_exception { /** * Constructor. * diff --git a/local/o365/classes/webservices/read_assignments.php b/local/o365/classes/webservices/read_assignments.php index 9bbd154ab..265b5cb0a 100644 --- a/local/o365/classes/webservices/read_assignments.php +++ b/local/o365/classes/webservices/read_assignments.php @@ -25,6 +25,9 @@ namespace local_o365\webservices; +use assign; +use context_course; +use context_module; use moodle_exception; defined('MOODLE_INTERNAL') || die(); @@ -36,12 +39,13 @@ use core_external\external_single_structure; use core_external\external_value; use core_external\external_warnings; +use moodle_url; global $CFG; -require_once($CFG->dirroot.'/course/modlib.php'); -require_once($CFG->dirroot.'/user/externallib.php'); -require_once($CFG->dirroot.'/mod/assign/locallib.php'); +require_once($CFG->dirroot . '/course/modlib.php'); +require_once($CFG->dirroot . '/user/externallib.php'); +require_once($CFG->dirroot . '/mod/assign/locallib.php'); /** * Get a list of assignments in one or more courses. @@ -68,7 +72,7 @@ public static function assignments_read_parameters() { VALUE_DEFAULT, [] ), - 'capabilities' => new external_multiple_structure( + 'capabilities' => new external_multiple_structure( new external_value(PARAM_CAPABILITY, 'capability'), 'list of capabilities used to filter courses', VALUE_DEFAULT, @@ -147,7 +151,7 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c foreach ($courseids as $cid) { try { - $context = \context_course::instance($cid); + $context = context_course::instance($cid); self::validate_context($context); // Check if this course was already loaded (by enrol_get_users_courses). @@ -169,30 +173,30 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c } } $extrafields = 'm.id as assignmentid, ' . - 'm.course, ' . - 'm.nosubmissions, ' . - 'm.submissiondrafts, ' . - 'm.sendnotifications, '. - 'm.sendlatenotifications, ' . - 'm.sendstudentnotifications, ' . - 'm.duedate, ' . - 'm.allowsubmissionsfromdate, '. - 'm.grade, ' . - 'm.timemodified, '. - 'm.completionsubmit, ' . - 'm.cutoffdate, ' . - 'm.teamsubmission, ' . - 'm.requireallteammemberssubmit, '. - 'm.teamsubmissiongroupingid, ' . - 'm.blindmarking, ' . - 'm.revealidentities, ' . - 'm.attemptreopenmethod, '. - 'm.maxattempts, ' . - 'm.markingworkflow, ' . - 'm.markingallocation, ' . - 'm.requiresubmissionstatement, '. - 'm.intro, '. - 'm.introformat'; + 'm.course, ' . + 'm.nosubmissions, ' . + 'm.submissiondrafts, ' . + 'm.sendnotifications, ' . + 'm.sendlatenotifications, ' . + 'm.sendstudentnotifications, ' . + 'm.duedate, ' . + 'm.allowsubmissionsfromdate, ' . + 'm.grade, ' . + 'm.timemodified, ' . + 'm.completionsubmit, ' . + 'm.cutoffdate, ' . + 'm.teamsubmission, ' . + 'm.requireallteammemberssubmit, ' . + 'm.teamsubmissiongroupingid, ' . + 'm.blindmarking, ' . + 'm.revealidentities, ' . + 'm.attemptreopenmethod, ' . + 'm.maxattempts, ' . + 'm.markingworkflow, ' . + 'm.markingallocation, ' . + 'm.requiresubmissionstatement, ' . + 'm.intro, ' . + 'm.introformat'; $coursearray = []; foreach ($courses as $id => $course) { @@ -206,7 +210,7 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c continue; } - $context = \context_module::instance($module->id); + $context = context_module::instance($module->id); try { self::validate_context($context); require_capability('mod/assign:view', $context); @@ -263,7 +267,7 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c ]; // Return or not intro and file attachments depending on the plugin settings. - $assign = new \assign($context, null, null); + $assign = new assign($context, null, null); if ($assign->show_intro()) { @@ -281,7 +285,7 @@ public static function assignments_read($courseids = [], $assignmentids = [], $c $assignment['introattachments'][] = [ 'filename' => $filename, 'mimetype' => $file->get_mimetype(), - 'fileurl' => \moodle_url::make_webservice_pluginfile_url( + 'fileurl' => moodle_url::make_webservice_pluginfile_url( $context->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0, '/', $filename)->out(false), ]; } @@ -411,5 +415,4 @@ public static function assignments_read_returns() { ] ); } - } diff --git a/local/o365/classes/webservices/read_courseusers.php b/local/o365/classes/webservices/read_courseusers.php index 3f39b0054..a5d21f523 100644 --- a/local/o365/classes/webservices/read_courseusers.php +++ b/local/o365/classes/webservices/read_courseusers.php @@ -25,6 +25,8 @@ namespace local_o365\webservices; +use context_course; +use context_helper; use moodle_exception; use stdClass; @@ -38,7 +40,7 @@ global $CFG; -require_once($CFG->dirroot.'/course/modlib.php'); +require_once($CFG->dirroot . '/course/modlib.php'); /** * Get a list of students in a course by course id. @@ -77,7 +79,7 @@ public static function courseusers_read_parameters() { */ public static function courseusers_read($courseid, $limitfrom = 0, $limitnumber = 0, $userids = []) { global $CFG, $DB; - require_once($CFG->dirroot.'/user/lib.php'); + require_once($CFG->dirroot . '/user/lib.php'); $params = self::validate_parameters( self::courseusers_read_parameters(), @@ -112,7 +114,7 @@ public static function courseusers_read($courseid, $limitfrom = 0, $limitnumber return []; } $course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST); - $context = \context_course::instance($courseid); + $context = context_course::instance($courseid); self::validate_context($context); try { @@ -121,7 +123,7 @@ public static function courseusers_read($courseid, $limitfrom = 0, $limitnumber $exceptionparam = new stdClass(); $exceptionparam->message = $e->getMessage(); $exceptionparam->courseid = $params['courseid']; - throw new moodle_exception('errorcoursecontextnotvalid' , 'webservice', '', $exceptionparam); + throw new moodle_exception('errorcoursecontextnotvalid', 'webservice', '', $exceptionparam); } require_capability('moodle/course:viewparticipants', $context); @@ -129,7 +131,7 @@ public static function courseusers_read($courseid, $limitfrom = 0, $limitnumber [$enrolledsql, $enrolledparams] = get_enrolled_sql($context, $withcapability); // For user context preloading. - $ctxselect = ', ' . \context_helper::get_preload_record_columns_sql('ctx'); + $ctxselect = ', ' . context_helper::get_preload_record_columns_sql('ctx'); $ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = u.id AND ctx.contextlevel = :contextlevel)"; $enrolledparams['contextlevel'] = CONTEXT_USER; @@ -166,7 +168,7 @@ public static function courseusers_read($courseid, $limitfrom = 0, $limitnumber } // Get user info. - \context_helper::preload_from_record($user); + context_helper::preload_from_record($user); if ($userdetails = user_get_user_details($user, $course, $userfields)) { $users[] = $userdetails; } @@ -179,7 +181,7 @@ public static function courseusers_read($courseid, $limitfrom = 0, $limitnumber /** * Returns description of method result value * - * @return external_description + * @return external_multiple_structure */ public static function courseusers_read_returns() { return new external_multiple_structure( diff --git a/local/o365/classes/webservices/read_onenoteassignment.php b/local/o365/classes/webservices/read_onenoteassignment.php index 6dfe02fb5..2b3f490b4 100644 --- a/local/o365/classes/webservices/read_onenoteassignment.php +++ b/local/o365/classes/webservices/read_onenoteassignment.php @@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die(); +use context_course; use core_external\external_api; use core_external\external_function_parameters; use core_external\external_single_structure; @@ -34,7 +35,7 @@ global $CFG; -require_once($CFG->dirroot.'/course/modlib.php'); +require_once($CFG->dirroot . '/course/modlib.php'); /** * Read assignment API class. @@ -63,13 +64,14 @@ public static function assignment_read_parameters() { public static function assignment_read($data) { $params = self::validate_parameters(self::assignment_read_parameters(), ['data' => $data]); $params = $params['data']; - list($course, $module, $assign) = \local_o365\webservices\utils::verify_assignment($params['coursemodule'], + [$course, $module, $assign] = utils::verify_assignment($params['coursemodule'], $params['course']); - $context = \context_course::instance($params['course']); + $context = context_course::instance($params['course']); self::validate_context($context); - $modinfo = \local_o365\webservices\utils::get_assignment_return_info($module->id, $course->id); + $modinfo = utils::get_assignment_return_info($module->id, $course->id); + return ['data' => [$modinfo]]; } @@ -79,6 +81,6 @@ public static function assignment_read($data) { * @return external_single_structure Object describing return parameters for this webservice method. */ public static function assignment_read_returns() { - return \local_o365\webservices\utils::get_assignment_return_info_schema(); + return utils::get_assignment_return_info_schema(); } } diff --git a/local/o365/classes/webservices/read_teachercourses.php b/local/o365/classes/webservices/read_teachercourses.php index ea3437c8f..15d09b7cf 100644 --- a/local/o365/classes/webservices/read_teachercourses.php +++ b/local/o365/classes/webservices/read_teachercourses.php @@ -25,6 +25,7 @@ namespace local_o365\webservices; +use context_course; use moodle_exception; defined('MOODLE_INTERNAL') || die(); @@ -37,7 +38,7 @@ global $CFG; -require_once($CFG->dirroot.'/course/modlib.php'); +require_once($CFG->dirroot . '/course/modlib.php'); /** * Get a list of courses where the current user is a teacher. @@ -86,12 +87,11 @@ public static function teachercourses_read($courseids = []) { $result = []; foreach ($courses as $course) { - if (!empty($courseids) && !isset($courseids[$course->id])) { continue; } - $context = \context_course::instance($course->id, IGNORE_MISSING); + $context = context_course::instance($course->id, IGNORE_MISSING); // Validate the user can execute functions in this course. try { @@ -124,7 +124,7 @@ public static function teachercourses_read($courseids = []) { /** * Returns description of method result value * - * @return external_description + * @return external_multiple_structure */ public static function teachercourses_read_returns() { return new external_multiple_structure( diff --git a/local/o365/classes/webservices/update_grade.php b/local/o365/classes/webservices/update_grade.php index 695d8930f..ac8fc8aa2 100644 --- a/local/o365/classes/webservices/update_grade.php +++ b/local/o365/classes/webservices/update_grade.php @@ -27,6 +27,9 @@ defined('MOODLE_INTERNAL') || die(); +use assign; +use context_module; +use grading_manager; use local_o365\webservices\exception as exception; use core_external\external_api; use core_external\external_function_parameters; @@ -36,9 +39,9 @@ global $CFG; -require_once($CFG->dirroot.'/course/modlib.php'); -require_once($CFG->dirroot.'/user/externallib.php'); -require_once($CFG->dirroot.'/mod/assign/locallib.php'); +require_once($CFG->dirroot . '/course/modlib.php'); +require_once($CFG->dirroot . '/user/externallib.php'); +require_once($CFG->dirroot . '/mod/assign/locallib.php'); /** * Update a grade. @@ -52,7 +55,7 @@ class update_grade extends external_api { public static function grade_update_parameters() { global $CFG; require_once("$CFG->dirroot/grade/grading/lib.php"); - $instance = new \assign(null, null, null); + $instance = new assign(null, null, null); $pluginfeedbackparams = []; foreach ($instance->get_feedback_plugins() as $plugin) { @@ -65,7 +68,7 @@ public static function grade_update_parameters() { } $advancedgradingdata = []; - $methods = array_keys(\grading_manager::available_methods(false)); + $methods = array_keys(grading_manager::available_methods(false)); foreach ($methods as $method) { require_once($CFG->dirroot . '/grade/grading/form/' . $method . '/lib.php'); $details = call_user_func('gradingform_' . $method . '_controller::get_external_instance_filling_details'); @@ -128,12 +131,12 @@ public static function grade_update($assignmentid, $userid, $grade, $attemptnumb 'advancedgradingdata' => $advancedgradingdata]); $cm = get_coursemodule_from_instance('assign', $params['assignmentid'], 0, false, MUST_EXIST); - $context = \context_module::instance($cm->id); + $context = context_module::instance($cm->id); self::validate_context($context); - $assignment = new \assign($context, $cm, null); + $assignment = new assign($context, $cm, null); - $gradedata = (object)$params['plugindata']; + $gradedata = (object) $params['plugindata']; $gradedata->addattempt = $params['addattempt']; $gradedata->attemptnumber = $params['attemptnumber']; diff --git a/local/o365/classes/webservices/update_onenoteassignment.php b/local/o365/classes/webservices/update_onenoteassignment.php index 77f577dfc..903b11c4f 100644 --- a/local/o365/classes/webservices/update_onenoteassignment.php +++ b/local/o365/classes/webservices/update_onenoteassignment.php @@ -27,6 +27,7 @@ defined('MOODLE_INTERNAL') || die(); +use context_course; use local_o365\webservices\exception as exception; use core_external\external_api; use core_external\external_function_parameters; @@ -35,7 +36,7 @@ global $CFG; -require_once($CFG->dirroot.'/course/modlib.php'); +require_once($CFG->dirroot . '/course/modlib.php'); /** * Update assignment API class. @@ -72,10 +73,10 @@ public static function assignment_update($data) { $params = self::validate_parameters(self::assignment_update_parameters(), ['data' => $data]); $params = $params['data']; - list($course, $module, $assign) = \local_o365\webservices\utils::verify_assignment($params['coursemodule'], + [$course, $module, $assign] = utils::verify_assignment($params['coursemodule'], $params['course']); - $context = \context_course::instance($params['course']); + $context = context_course::instance($params['course']); self::validate_context($context); // Update assignment information. @@ -84,7 +85,7 @@ public static function assignment_update($data) { $updatedassigninfo['name'] = $params['name']; } if (isset($params['intro']) && $params['intro'] !== null) { - $updatedassigninfo['introeditor'] = ['text' => (string)$params['intro'], 'format' => FORMAT_HTML, 'itemid' => null]; + $updatedassigninfo['introeditor'] = ['text' => (string) $params['intro'], 'format' => FORMAT_HTML, 'itemid' => null]; } if (!empty($updatedassigninfo)) { $assignkeys = [ @@ -107,7 +108,7 @@ public static function assignment_update($data) { $assigninfo = [ 'coursemodule' => $module->id, 'cmidnumber' => $module->idnumber, - 'introeditor' => ['text' => (string)$assign->intro, 'format' => FORMAT_HTML, 'itemid' => null], + 'introeditor' => ['text' => (string) $assign->intro, 'format' => FORMAT_HTML, 'itemid' => null], 'assignsubmission_onenote_enabled' => 1, 'assignsubmission_onenote_maxfiles' => 1, 'assignsubmission_onenote_maxsizebytes' => 1024, @@ -120,7 +121,7 @@ public static function assignment_update($data) { } $assigninfo = array_merge($assigninfo, $updatedassigninfo); - update_module((object)$assigninfo); + update_module((object) $assigninfo); } // Update module visibility if requested. @@ -139,7 +140,8 @@ public static function assignment_update($data) { moveto_module($module, $section); } - $modinfo = \local_o365\webservices\utils::get_assignment_return_info($module->id, $course->id); + $modinfo = utils::get_assignment_return_info($module->id, $course->id); + return ['data' => [$modinfo]]; } @@ -149,6 +151,6 @@ public static function assignment_update($data) { * @return external_single_structure Object describing return parameters for this webservice method. */ public static function assignment_update_returns() { - return \local_o365\webservices\utils::get_assignment_return_info_schema(); + return utils::get_assignment_return_info_schema(); } } diff --git a/local/o365/classes/webservices/utils.php b/local/o365/classes/webservices/utils.php index f9f2333c9..cb022c68e 100644 --- a/local/o365/classes/webservices/utils.php +++ b/local/o365/classes/webservices/utils.php @@ -86,6 +86,7 @@ public static function get_assignment_return_info_schema() { ]) ), ]; + return new external_single_structure($params); } @@ -110,6 +111,7 @@ public static function get_assignment_info($coursemoduleid, $courseid) { if (empty($assign)) { throw new exception\assignnotfound(); } + return [$course, $module, $assign]; } @@ -122,6 +124,7 @@ public static function get_assignment_info($coursemoduleid, $courseid) { */ public static function get_assignment_return_info($coursemoduleid, $courseid) { [$course, $module, $assign] = static::get_assignment_info($coursemoduleid, $courseid); + return [ 'course' => $course->id, 'coursemodule' => $module->id,