Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

External assign API

Copyright: 2012 Paul Charsley
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 2960 lines (132 kb)
Included or required:0 times
Referenced: 24 times
Includes or requires: 0 files

Defines 1 class

mod_assign_external:: (82 methods):
  generate_warning()
  get_grades_parameters()
  get_grades()
  get_grade_structure()
  assign_grades()
  get_grades_returns()
  get_assignments_parameters()
  get_assignments()
  get_assignments_assignment_structure()
  get_assignments_config_structure()
  get_assignments_course_structure()
  get_assignments_returns()
  get_plugins_data()
  get_submissions_parameters()
  get_submissions()
  get_plugin_structure()
  get_submission_structure()
  get_submissions_structure()
  get_submissions_returns()
  set_user_flags_parameters()
  set_user_flags()
  set_user_flags_returns()
  get_user_flags_parameters()
  get_user_flags()
  assign_user_flags()
  get_user_flags_returns()
  get_user_mappings_parameters()
  get_user_mappings()
  assign_user_mappings()
  get_user_mappings_returns()
  lock_submissions_parameters()
  lock_submissions()
  lock_submissions_returns()
  revert_submissions_to_draft_parameters()
  revert_submissions_to_draft()
  revert_submissions_to_draft_returns()
  unlock_submissions_parameters()
  unlock_submissions()
  unlock_submissions_returns()
  submit_grading_form_parameters()
  submit_grading_form()
  submit_grading_form_returns()
  submit_for_grading_parameters()
  submit_for_grading()
  submit_for_grading_returns()
  save_user_extensions_parameters()
  save_user_extensions()
  save_user_extensions_returns()
  reveal_identities_parameters()
  reveal_identities()
  reveal_identities_returns()
  save_submission_parameters()
  save_submission()
  save_submission_returns()
  save_grade_parameters()
  save_grade()
  save_grade_returns()
  save_grades_parameters()
  save_grades()
  save_grades_returns()
  copy_previous_attempt_parameters()
  copy_previous_attempt()
  copy_previous_attempt_returns()
  view_grading_table_parameters()
  view_grading_table()
  view_grading_table_returns()
  view_submission_status_parameters()
  view_submission_status()
  view_submission_status_returns()
  get_submission_status_parameters()
  get_submission_status()
  get_submission_status_returns()
  list_participants_parameters()
  list_participants()
  list_participants_returns()
  get_participant_parameters()
  get_participant()
  get_participant_returns()
  validate_assign()
  view_assign_parameters()
  view_assign()
  view_assign_returns()


Class: mod_assign_external  - X-Ref

Assign functions

generate_warning($assignmentid, $warningcode, $detail)   X-Ref
Generate a warning in a standard structure for a known failure.

param: int $assignmentid - The assignment
param: string $warningcode - The key for the warning message
param: string $detail - A description of the error
return: array - Warning structure containing item, itemid, warningcode, message

get_grades_parameters()   X-Ref
Describes the parameters for get_grades

return: external_function_parameters

get_grades($assignmentids, $since = 0)   X-Ref
Returns grade information from assign_grades for the requested assignment ids

param: int[] $assignmentids
param: int $since only return records with timemodified >= since
return: array of grade records for each requested assignment

get_grade_structure($required = VALUE_REQUIRED)   X-Ref
Creates a grade single structure.

return: external_single_structure a grade single structure.

assign_grades()   X-Ref
Creates an assign_grades external_single_structure

return: external_single_structure

get_grades_returns()   X-Ref
Describes the get_grades return value

return: external_single_structure

get_assignments_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

get_assignments($courseids = array()   X-Ref
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.

param: array $courseids An optional array of course ids. If provided only assignments within the given course
param: array $capabilities An array of additional capability checks you wish to be made on the course context.
param: bool $includenotenrolledcourses Wheter to return courses that the user can see even if is not enroled in.
return: An array of courses and warnings.

get_assignments_assignment_structure()   X-Ref
Creates an assignment external_single_structure

return: external_single_structure

get_assignments_config_structure()   X-Ref
Creates an assign_plugin_config external_single_structure

return: external_single_structure

get_assignments_course_structure()   X-Ref
Creates a course external_single_structure

return: external_single_structure

get_assignments_returns()   X-Ref
Describes the return value for get_assignments

return: external_single_structure

get_plugins_data($assign, $assignplugins, $item)   X-Ref
Return information (files and text fields) for the given plugins in the assignment.

param: assign $assign the assignment object
param: array $assignplugins array of assignment plugins (submission or feedback)
param: stdClass $item the item object (submission or grade)
return: array an array containing the plugins returned information

get_submissions_parameters()   X-Ref
Describes the parameters for get_submissions

return: external_function_parameters

get_submissions($assignmentids, $status = '', $since = 0, $before = 0)   X-Ref
Returns submissions for the requested assignment ids

param: int[] $assignmentids
param: string $status only return submissions with this status
param: int $since only return submissions with timemodified >= since
param: int $before only return submissions with timemodified <= before
return: array of submissions for each requested assignment

get_plugin_structure()   X-Ref
Creates an assignment plugin structure.

return: external_single_structure the plugin structure

get_submission_structure($required = VALUE_REQUIRED)   X-Ref
Creates a submission structure.

return: external_single_structure the submission structure

get_submissions_structure()   X-Ref
Creates an assign_submissions external_single_structure

return: external_single_structure

get_submissions_returns()   X-Ref
Describes the get_submissions return value

return: external_single_structure

set_user_flags_parameters()   X-Ref
Describes the parameters for set_user_flags

return: external_function_parameters

set_user_flags($assignmentid, $userflags = array()   X-Ref
Create or update user_flags records

param: int $assignmentid the assignment for which the userflags are created or updated
param: array $userflags  An array of userflags to create or update
return: array containing success or failure information for each record

set_user_flags_returns()   X-Ref
Describes the set_user_flags return value

return: external_multiple_structure

get_user_flags_parameters()   X-Ref
Describes the parameters for get_user_flags

return: external_function_parameters

get_user_flags($assignmentids)   X-Ref
Returns user flag information from assign_user_flags for the requested assignment ids

param: int[] $assignmentids
return: array of user flag records for each requested assignment

assign_user_flags()   X-Ref
Creates an assign_user_flags external_single_structure

return: external_single_structure

get_user_flags_returns()   X-Ref
Describes the get_user_flags return value

return: external_single_structure

get_user_mappings_parameters()   X-Ref
Describes the parameters for get_user_mappings

return: external_function_parameters

get_user_mappings($assignmentids)   X-Ref
Returns user mapping information from assign_user_mapping for the requested assignment ids

param: int[] $assignmentids
return: array of user mapping records for each requested assignment

assign_user_mappings()   X-Ref
Creates an assign_user_mappings external_single_structure

return: external_single_structure

get_user_mappings_returns()   X-Ref
Describes the get_user_mappings return value

return: external_single_structure

lock_submissions_parameters()   X-Ref
Describes the parameters for lock_submissions

return: external_function_parameters

lock_submissions($assignmentid, $userids)   X-Ref
Locks (prevent updates to) submissions in this assignment.

param: int $assignmentid The id of the assignment
param: array $userids Array of user ids to lock
return: array of warnings for each submission that could not be locked.

lock_submissions_returns()   X-Ref
Describes the return value for lock_submissions

return: external_single_structure

revert_submissions_to_draft_parameters()   X-Ref
Describes the parameters for revert_submissions_to_draft

return: external_function_parameters

revert_submissions_to_draft($assignmentid, $userids)   X-Ref
Reverts a list of user submissions to draft for a single assignment.

param: int $assignmentid The id of the assignment
param: array $userids Array of user ids to revert
return: array of warnings for each submission that could not be reverted.

revert_submissions_to_draft_returns()   X-Ref
Describes the return value for revert_submissions_to_draft

return: external_single_structure

unlock_submissions_parameters()   X-Ref
Describes the parameters for unlock_submissions

return: external_function_parameters

unlock_submissions($assignmentid, $userids)   X-Ref
Locks (prevent updates to) submissions in this assignment.

param: int $assignmentid The id of the assignment
param: array $userids Array of user ids to lock
return: array of warnings for each submission that could not be locked.

unlock_submissions_returns()   X-Ref
Describes the return value for unlock_submissions

return: external_single_structure

submit_grading_form_parameters()   X-Ref
Describes the parameters for submit_grading_form webservice.

return: external_function_parameters

submit_grading_form($assignmentid, $userid, $jsonformdata)   X-Ref
Submit the logged in users assignment for grading.

param: int $assignmentid The id of the assignment
param: int $userid The id of the user the submission belongs to.
param: string $jsonformdata The data from the form, encoded as a json array.
return: array of warnings to indicate any errors.

submit_grading_form_returns()   X-Ref
Describes the return for submit_grading_form

return: external_function_parameters

submit_for_grading_parameters()   X-Ref
Describes the parameters for submit_for_grading

return: external_function_parameters

submit_for_grading($assignmentid, $acceptsubmissionstatement)   X-Ref
Submit the logged in users assignment for grading.

param: int $assignmentid The id of the assignment
return: array of warnings to indicate any errors.

submit_for_grading_returns()   X-Ref
Describes the return value for submit_for_grading

return: external_single_structure

save_user_extensions_parameters()   X-Ref
Describes the parameters for save_user_extensions

return: external_function_parameters

save_user_extensions($assignmentid, $userids, $dates)   X-Ref
Grant extension dates to students for an assignment.

param: int $assignmentid The id of the assignment
param: array $userids Array of user ids to grant extensions to
param: array $dates Array of extension dates
return: array of warnings for each extension date that could not be granted

save_user_extensions_returns()   X-Ref
Describes the return value for save_user_extensions

return: external_single_structure

reveal_identities_parameters()   X-Ref
Describes the parameters for reveal_identities

return: external_function_parameters

reveal_identities($assignmentid)   X-Ref
Reveal the identities of anonymous students to markers for a single assignment.

param: int $assignmentid The id of the assignment
return: array of warnings to indicate any errors.

reveal_identities_returns()   X-Ref
Describes the return value for reveal_identities

return: external_single_structure

save_submission_parameters()   X-Ref
Describes the parameters for save_submission

return: external_function_parameters

save_submission($assignmentid, $plugindata)   X-Ref
Save a student submission for a single assignment

param: int $assignmentid The id of the assignment
param: array $plugindata - The submitted data for plugins
return: array of warnings to indicate any errors

save_submission_returns()   X-Ref
Describes the return value for save_submission

return: external_single_structure

save_grade_parameters()   X-Ref
Describes the parameters for save_grade

return: external_function_parameters

save_grade($assignmentid,$userid,$grade,$attemptnumber,$addattempt,$workflowstate,$applytoall,$plugindata = array()   X-Ref
Save a student grade for a single assignment.

param: int $assignmentid The id of the assignment
param: int $userid The id of the user
param: float $grade The grade (ignored if the assignment uses advanced grading)
param: int $attemptnumber The attempt number
param: bool $addattempt Allow another attempt
param: string $workflowstate New workflow state
param: bool $applytoall Apply the grade to all members of the group
param: array $plugindata Custom data used by plugins
param: array $advancedgradingdata Advanced grading data
return: null

save_grade_returns()   X-Ref
Describes the return value for save_grade

return: external_single_structure

save_grades_parameters()   X-Ref
Describes the parameters for save_grades

return: external_function_parameters

save_grades($assignmentid, $applytoall = false, $grades)   X-Ref
Save multiple student grades for a single assignment.

param: int $assignmentid The id of the assignment
param: boolean $applytoall If set to true and this is a team assignment,
param: array $grades grade data for one or more students that includes
return: null

save_grades_returns()   X-Ref
Describes the return value for save_grades

return: external_single_structure

copy_previous_attempt_parameters()   X-Ref
Describes the parameters for copy_previous_attempt

return: external_function_parameters

copy_previous_attempt($assignmentid)   X-Ref
Copy a students previous attempt to a new attempt.

param: int $assignmentid
return: array of warnings to indicate any errors.

copy_previous_attempt_returns()   X-Ref
Describes the return value for save_submission

return: external_single_structure

view_grading_table_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

view_grading_table($assignid)   X-Ref
Trigger the grading_table_viewed event.

param: int $assignid the assign instance id
return: array of warnings and status result

view_grading_table_returns()   X-Ref
Returns description of method result value

return: external_description

view_submission_status_parameters()   X-Ref
Describes the parameters for view_submission_status.

return: external_function_parameters

view_submission_status($assignid)   X-Ref
Trigger the submission status viewed event.

param: int $assignid assign instance id
return: array of warnings and status result

view_submission_status_returns()   X-Ref
Describes the view_submission_status return value.

return: external_single_structure

get_submission_status_parameters()   X-Ref
Describes the parameters for get_submission_status.

return: external_function_parameters

get_submission_status($assignid, $userid = 0, $groupid = 0)   X-Ref
Returns information about an assignment submission status for a given user.

param: int $assignid assignment instance id
param: int $userid user id (empty for current user)
param: int $groupid filter by users in group id (used for generating the grading summary). Use 0 for all groups information.
return: array of warnings and grading, status, feedback and previous attempts information

get_submission_status_returns()   X-Ref
No description

list_participants_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

list_participants($assignid, $groupid, $filter, $skip,$limit, $onlyids, $includeenrolments, $tablesort)   X-Ref
Retrieves the list of students to be graded for the assignment.

param: int $assignid the assign instance id
param: int $groupid the current group id
param: string $filter search string to filter the results.
param: int $skip Number of records to skip
param: int $limit Maximum number of records to return
param: bool $onlyids Only return user ids.
param: bool $includeenrolments Return courses where the user is enrolled.
param: bool $tablesort Apply current user table sorting params from the grading table.
return: array of warnings and status result

list_participants_returns()   X-Ref
Returns the description of the results of the mod_assign_external::list_participants() method.

return: external_description

get_participant_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

get_participant($assignid, $userid, $embeduser)   X-Ref
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.

param: int $assignid the assign instance id
param: int $userid the user id
param: bool $embeduser return user details (only applicable if not blind marking)
return: array of warnings and status result

get_participant_returns()   X-Ref
Returns description of method result value

return: external_description

validate_assign($assignid)   X-Ref
Utility function for validating an assign.

param: int $assignid assign instance id
return: array array containing the assign, course, context and course module objects

view_assign_parameters()   X-Ref
Describes the parameters for view_assign.

return: external_function_parameters

view_assign($assignid)   X-Ref
Update the module completion status.

param: int $assignid assign instance id
return: array of warnings and status result

view_assign_returns()   X-Ref
Describes the view_assign return value.

return: external_single_structure