Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 115 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

external_api:: (3 methods):
  generate_warning()
  validate_assign()
  get_user_or_group_submission()


Class: external_api  - X-Ref

Extend the base external_api class with mod_assign utility methods.

generate_warning(int $assignmentid, string $warningcode, string $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

validate_assign(int $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

get_user_or_group_submission(\assign $assignment, int $userid = null,int $groupid = 0, bool $create = false, int $attemptnumber = -1)   X-Ref
Get a submission from an assignment for a user. Encapsulates checking whether it's a solo or team submission.

param: \assign $assignment Assignment object.
param: int|null $userid User id.
param: int $groupid Group id.
param: bool $create Whether a new submission should be created.
param: int $attemptnumber Attempt number. Use -1 for last attempt.
return: bool|\stdClass