Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Assign functions. More...
Static Public Member Functions | |
static | call_external_function ($function, $args, $ajaxonly=false) |
Call an external function validating all params/returns correctly. More... | |
static | clean_returnvalue (external_description $description, $response) |
Clean response If a response attribute is unknown from the description, we just ignore the attribute. More... | |
static | copy_previous_attempt ($assignmentid) |
Copy a students previous attempt to a new attempt. More... | |
static | copy_previous_attempt_parameters () |
Describes the parameters for copy_previous_attempt. More... | |
static | copy_previous_attempt_returns () |
Describes the return value for save_submission. More... | |
static | external_function_info ($function, $strictness=MUST_EXIST) |
Returns detailed function information. More... | |
static | get_assignments ($courseids=array(), $capabilities=array(), $includenotenrolledcourses=false) |
Returns an array of courses the user is enrolled, and for each course all of the assignments that the user can view within that course. More... | |
static | get_assignments_parameters () |
Returns description of method parameters. More... | |
static | get_assignments_returns () |
Describes the return value for get_assignments. More... | |
static | get_grades ($assignmentids, $since=0) |
Returns grade information from assign_grades for the requested assignment ids. More... | |
static | get_grades_parameters () |
Describes the parameters for get_grades. More... | |
static | get_grades_returns () |
Describes the get_grades return value. More... | |
static | get_participant ($assignid, $userid, $embeduser) |
Get the user participating in the given assignment. More... | |
static | get_participant_parameters () |
Returns description of method parameters. More... | |
static | get_participant_returns () |
Returns description of method result value. More... | |
static | get_submission_status ($assignid, $userid=0, $groupid=0) |
Returns information about an assignment submission status for a given user. More... | |
static | get_submission_status_parameters () |
Describes the parameters for get_submission_status. More... | |
static | get_submission_status_returns () |
Describes the get_submission_status return value. More... | |
static | get_submissions ($assignmentids, $status='', $since=0, $before=0) |
Returns submissions for the requested assignment ids. More... | |
static | get_submissions_parameters () |
Describes the parameters for get_submissions. More... | |
static | get_submissions_returns () |
Describes the get_submissions return value. More... | |
static | get_user_flags ($assignmentids) |
Returns user flag information from assign_user_flags for the requested assignment ids. More... | |
static | get_user_flags_parameters () |
Describes the parameters for get_user_flags. More... | |
static | get_user_flags_returns () |
Describes the get_user_flags return value. More... | |
static | get_user_mappings ($assignmentids) |
Returns user mapping information from assign_user_mapping for the requested assignment ids. More... | |
static | get_user_mappings_parameters () |
Describes the parameters for get_user_mappings. More... | |
static | get_user_mappings_returns () |
Describes the get_user_mappings return value. More... | |
static | list_participants ($assignid, $groupid, $filter, $skip, $limit, $onlyids, $includeenrolments, $tablesort) |
Retrieves the list of students to be graded for the assignment. More... | |
static | list_participants_parameters () |
Returns description of method parameters. More... | |
static | list_participants_returns () |
Returns the description of the results of the mod_assign_external::list_participants() method. More... | |
static | lock_submissions ($assignmentid, $userids) |
Locks (prevent updates to) submissions in this assignment. More... | |
static | lock_submissions_parameters () |
Describes the parameters for lock_submissions. More... | |
static | lock_submissions_returns () |
Describes the return value for lock_submissions. More... | |
static | reveal_identities ($assignmentid) |
Reveal the identities of anonymous students to markers for a single assignment. More... | |
static | reveal_identities_parameters () |
Describes the parameters for reveal_identities. More... | |
static | reveal_identities_returns () |
Describes the return value for reveal_identities. More... | |
static | revert_submissions_to_draft ($assignmentid, $userids) |
Reverts a list of user submissions to draft for a single assignment. More... | |
static | revert_submissions_to_draft_parameters () |
Describes the parameters for revert_submissions_to_draft. More... | |
static | revert_submissions_to_draft_returns () |
Describes the return value for revert_submissions_to_draft. More... | |
static | save_grade ($assignmentid, $userid, $grade, $attemptnumber, $addattempt, $workflowstate, $applytoall, $plugindata=array(), $advancedgradingdata=array()) |
Save a student grade for a single assignment. More... | |
static | save_grade_parameters () |
Describes the parameters for save_grade. More... | |
static | save_grade_returns () |
Describes the return value for save_grade. More... | |
static | save_grades ($assignmentid, $applytoall=false, $grades) |
Save multiple student grades for a single assignment. More... | |
static | save_grades_parameters () |
Describes the parameters for save_grades. More... | |
static | save_grades_returns () |
Describes the return value for save_grades. More... | |
static | save_submission ($assignmentid, $plugindata) |
Save a student submission for a single assignment. More... | |
static | save_submission_parameters () |
Describes the parameters for save_submission. More... | |
static | save_submission_returns () |
Describes the return value for save_submission. More... | |
static | save_user_extensions ($assignmentid, $userids, $dates) |
Grant extension dates to students for an assignment. More... | |
static | save_user_extensions_parameters () |
Describes the parameters for save_user_extensions. More... | |
static | save_user_extensions_returns () |
Describes the return value for save_user_extensions. More... | |
static | set_context_restriction ($context) |
Set context restriction for all following subsequent function calls. More... | |
static | set_timeout ($seconds=360) |
This method has to be called before every operation that takes a longer time to finish! More... | |
static | set_user_flags ($assignmentid, $userflags=array()) |
Create or update user_flags records. More... | |
static | set_user_flags_parameters () |
Describes the parameters for set_user_flags. More... | |
static | set_user_flags_returns () |
Describes the set_user_flags return value. More... | |
static | submit_for_grading ($assignmentid, $acceptsubmissionstatement) |
Submit the logged in users assignment for grading. More... | |
static | submit_for_grading_parameters () |
Describes the parameters for submit_for_grading. More... | |
static | submit_for_grading_returns () |
Describes the return value for submit_for_grading. More... | |
static | submit_grading_form ($assignmentid, $userid, $jsonformdata) |
Submit the logged in users assignment for grading. More... | |
static | submit_grading_form_parameters () |
Describes the parameters for submit_grading_form webservice. More... | |
static | submit_grading_form_returns () |
Describes the return for submit_grading_form. More... | |
static | unlock_submissions ($assignmentid, $userids) |
Locks (prevent updates to) submissions in this assignment. More... | |
static | unlock_submissions_parameters () |
Describes the parameters for unlock_submissions. More... | |
static | unlock_submissions_returns () |
Describes the return value for unlock_submissions. More... | |
static | validate_context ($context) |
Makes sure user may execute functions in this context. More... | |
static | validate_parameters (external_description $description, $params) |
Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown. More... | |
static | view_assign ($assignid) |
Update the module completion status. More... | |
static | view_assign_parameters () |
Describes the parameters for view_assign. More... | |
static | view_assign_returns () |
Describes the view_assign return value. More... | |
static | view_grading_table ($assignid) |
Trigger the grading_table_viewed event. More... | |
static | view_grading_table_parameters () |
Returns description of method parameters. More... | |
static | view_grading_table_returns () |
Returns description of method result value. More... | |
static | view_submission_status ($assignid) |
Trigger the submission status viewed event. More... | |
static | view_submission_status_parameters () |
Describes the parameters for view_submission_status. More... | |
static | view_submission_status_returns () |
Describes the view_submission_status return value. More... | |
Static Protected Member Functions | |
static | get_context_from_params ($param) |
Get context from passed parameters. More... | |
static | get_context_parameters () |
Returns a prepared structure to use a context parameters. More... | |
static | validate_assign ($assignid) |
Utility function for validating an assign. More... | |
Assign functions.
|
staticinherited |
Call an external function validating all params/returns correctly.
Note that an external function may modify the state of the current page, so this wrapper saves and restores tha PAGE and COURSE global variables before/after calling the external function.
string | $function | A webservice function name. |
array | $args | Params array (named params) |
boolean | $ajaxonly | If true, an extra check will be peformed to see if ajax is required. |
array | containing keys for error (bool), exception and data. |
|
staticinherited |
Clean response If a response attribute is unknown from the description, we just ignore the attribute.
If a response attribute is incorrect, invalid_response_exception is thrown. Note: this function is similar to validate parameters, however it is distinct because parameters validation must be distinct from cleaning return values.
external_description | $description | description of the return values |
mixed | $response | the actual response |
mixed | response with added defaults for optional items, invalid_response_exception thrown if any problem found |
|
static |
Copy a students previous attempt to a new attempt.
int | $assignmentid |
array | of warnings to indicate any errors. |
|
static |
Describes the parameters for copy_previous_attempt.
external_function_parameters |
|
static |
Describes the return value for save_submission.
external_single_structure |
|
staticinherited |
Returns detailed function information.
string | object | $function | name of external function or record from external_function |
int | $strictness | IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; MUST_EXIST means throw exception if no record or multiple records found |
stdClass | description or false if not found or exception thrown |
|
static |
Returns an array of courses the user is enrolled, and for each course all of the assignments that the user can view within that course.
array | $courseids | An optional array of course ids. If provided only assignments within the given course will be returned. If the user is not enrolled in or can't view a given course a warning will be generated and returned. |
array | $capabilities | An array of additional capability checks you wish to be made on the course context. |
bool | $includenotenrolledcourses | Wheter to return courses that the user can see even if is not enroled in. This requires the parameter $courseids to not be empty. |
An | array of courses and warnings. |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
Describes the return value for get_assignments.
external_single_structure |
|
staticprotectedinherited |
Get context from passed parameters.
The passed array must either contain a contextid or a combination of context level and instance id to fetch the context. For example, the context level can be "course" and instanceid can be courseid.
See context_helper::get_all_levels() for a list of valid context levels.
array | $param |
invalid_parameter_exception |
context |
|
staticprotectedinherited |
Returns a prepared structure to use a context parameters.
external_single_structure |
Reimplemented in core_competency\external, and tool_lp\external.
|
static |
Returns grade information from assign_grades for the requested assignment ids.
int[] | $assignmentids | |
int | $since | only return records with timemodified >= since |
array | of grade records for each requested assignment |
|
static |
|
static |
|
static |
Get the user participating in the given assignment.
An error with code 'usernotincourse' is thrown is the user isn't a participant of the given assignment.
int | $assignid | the assign instance id |
int | $userid | the user id |
bool | $embeduser | return user details (only applicable if not blind marking) |
array | of warnings and status result |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
|
static |
Returns information about an assignment submission status for a given user.
int | $assignid | assignment instance id |
int | $userid | user id (empty for current user) |
int | $groupid | filter by users in group id (used for generating the grading summary). Use 0 for all groups information. |
array | of warnings and grading, status, feedback and previous attempts information |
required_capability_exception |
|
static |
Describes the parameters for get_submission_status.
external_function_parameters |
|
static |
Describes the get_submission_status return value.
external_single_structure |
|
static |
Returns submissions for the requested assignment ids.
int[] | $assignmentids | |
string | $status | only return submissions with this status |
int | $since | only return submissions with timemodified >= since |
int | $before | only return submissions with timemodified <= before |
array | of submissions for each requested assignment |
|
static |
Describes the parameters for get_submissions.
external_function_parameters |
|
static |
|
static |
Returns user flag information from assign_user_flags for the requested assignment ids.
int[] | $assignmentids |
array | of user flag records for each requested assignment |
|
static |
Describes the parameters for get_user_flags.
external_function_parameters |
|
static |
|
static |
Returns user mapping information from assign_user_mapping for the requested assignment ids.
int[] | $assignmentids |
array | of user mapping records for each requested assignment |
|
static |
Describes the parameters for get_user_mappings.
external_function_parameters |
|
static |
Describes the get_user_mappings return value.
external_single_structure |
|
static |
Retrieves the list of students to be graded for the assignment.
int | $assignid | the assign instance id |
int | $groupid | the current group id |
string | $filter | search string to filter the results. |
int | $skip | Number of records to skip |
int | $limit | Maximum number of records to return |
bool | $onlyids | Only return user ids. |
bool | $includeenrolments | Return courses where the user is enrolled. |
bool | $tablesort | Apply current user table sorting params from the grading table. |
array | of warnings and status result |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
Returns the description of the results of the mod_assign_external::list_participants() method.
external_description |
|
static |
Locks (prevent updates to) submissions in this assignment.
int | $assignmentid | The id of the assignment |
array | $userids | Array of user ids to lock |
array | of warnings for each submission that could not be locked. |
|
static |
Describes the parameters for lock_submissions.
external_function_parameters |
|
static |
Describes the return value for lock_submissions.
external_single_structure |
|
static |
Reveal the identities of anonymous students to markers for a single assignment.
int | $assignmentid | The id of the assignment |
array | of warnings to indicate any errors. |
|
static |
Describes the parameters for reveal_identities.
external_function_parameters |
|
static |
Describes the return value for reveal_identities.
external_single_structure |
|
static |
Reverts a list of user submissions to draft for a single assignment.
int | $assignmentid | The id of the assignment |
array | $userids | Array of user ids to revert |
array | of warnings for each submission that could not be reverted. |
|
static |
Describes the parameters for revert_submissions_to_draft.
external_function_parameters |
|
static |
Describes the return value for revert_submissions_to_draft.
external_single_structure |
|
static |
Save a student grade for a single assignment.
int | $assignmentid | The id of the assignment |
int | $userid | The id of the user |
float | $grade | The grade (ignored if the assignment uses advanced grading) |
int | $attemptnumber | The attempt number |
bool | $addattempt | Allow another attempt |
string | $workflowstate | New workflow state |
bool | $applytoall | Apply the grade to all members of the group |
array | $plugindata | Custom data used by plugins |
array | $advancedgradingdata | Advanced grading data |
null |
|
static |
|
static |
|
static |
Save multiple student grades for a single assignment.
int | $assignmentid | The id of the assignment |
boolean | $applytoall | If set to true and this is a team assignment, apply the grade to all members of the group |
array | $grades | grade data for one or more students that includes userid - The id of the student being graded grade - The grade (ignored if the assignment uses advanced grading) attemptnumber - The attempt number addattempt - Allow another attempt workflowstate - New workflow state plugindata - Custom data used by plugins advancedgradingdata - Optional Advanced grading data |
invalid_parameter_exception | if multiple grades are supplied for a team assignment that has $applytoall set to true |
null |
|
static |
Describes the parameters for save_grades.
external_function_parameters |
|
static |
|
static |
Save a student submission for a single assignment.
int | $assignmentid | The id of the assignment |
array | $plugindata | - The submitted data for plugins |
array | of warnings to indicate any errors |
|
static |
Describes the parameters for save_submission.
external_function_parameters |
|
static |
Describes the return value for save_submission.
external_single_structure |
|
static |
Grant extension dates to students for an assignment.
int | $assignmentid | The id of the assignment |
array | $userids | Array of user ids to grant extensions to |
array | $dates | Array of extension dates |
array | of warnings for each extension date that could not be granted |
|
static |
Describes the parameters for save_user_extensions.
external_function_parameters |
|
static |
Describes the return value for save_user_extensions.
external_single_structure |
|
staticinherited |
Set context restriction for all following subsequent function calls.
stdClass | $context | the context restriction |
|
staticinherited |
This method has to be called before every operation that takes a longer time to finish!
int | $seconds | max expected time the next operation needs |
|
static |
Create or update user_flags records.
int | $assignmentid | the assignment for which the userflags are created or updated |
array | $userflags | An array of userflags to create or update |
array | containing success or failure information for each record |
|
static |
Describes the parameters for set_user_flags.
external_function_parameters |
|
static |
Describes the set_user_flags return value.
external_multiple_structure |
|
static |
Submit the logged in users assignment for grading.
int | $assignmentid | The id of the assignment |
array | of warnings to indicate any errors. |
|
static |
Describes the parameters for submit_for_grading.
external_function_parameters |
|
static |
Describes the return value for submit_for_grading.
external_single_structure |
|
static |
Submit the logged in users assignment for grading.
int | $assignmentid | The id of the assignment |
int | $userid | The id of the user the submission belongs to. |
string | $jsonformdata | The data from the form, encoded as a json array. |
array | of warnings to indicate any errors. |
|
static |
Describes the parameters for submit_grading_form webservice.
external_function_parameters |
|
static |
Describes the return for submit_grading_form.
external_function_parameters |
|
static |
Locks (prevent updates to) submissions in this assignment.
int | $assignmentid | The id of the assignment |
array | $userids | Array of user ids to lock |
array | of warnings for each submission that could not be locked. |
|
static |
Describes the parameters for unlock_submissions.
external_function_parameters |
|
static |
Describes the return value for unlock_submissions.
external_single_structure |
|
staticprotected |
Utility function for validating an assign.
int | $assignid | assign instance id |
array | array containing the assign, course, context and course module objects |
|
staticinherited |
Makes sure user may execute functions in this context.
stdClass | $context |
|
staticinherited |
Validates submitted function parameters, if anything is incorrect invalid_parameter_exception is thrown.
This is a simple recursive method which is intended to be called from each implementation method of external API.
external_description | $description | description of parameters |
mixed | $params | the actual parameters |
mixed | params with added defaults for optional items, invalid_parameters_exception thrown if any problem found |
|
static |
Update the module completion status.
int | $assignid | assign instance id |
array | of warnings and status result |
|
static |
Describes the parameters for view_assign.
external_function_parameters |
|
static |
|
static |
Trigger the grading_table_viewed event.
int | $assignid | the assign instance id |
array | of warnings and status result |
moodle_exception |
|
static |
Returns description of method parameters.
external_function_parameters |
|
static |
|
static |
Trigger the submission status viewed event.
int | $assignid | assign instance id |
array | of warnings and status result |
|
static |
Describes the parameters for view_submission_status.
external_function_parameters |
|
static |
Describes the view_submission_status return value.
external_single_structure |