Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

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

This file contains the definition for the class assignment This class provides all the functionality for the new assign module.

Copyright: 2012 NetSpot {@link http://www.netspot.com.au}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 10072 lines (416 kb)
Included or required: 2 times
Referenced: 51 times
Includes or requires: 1 file
 mod/assign/locallib.php

Defines 2 classes

assign:: (227 methods):
  __construct()
  register_return_link()
  get_return_action()
  show_intro()
  get_return_params()
  set_instance()
  set_context()
  set_course()
  set_error_message()
  get_error_messages()
  get_feedback_plugins()
  get_submission_plugins()
  is_blind_marking()
  is_hidden_grader()
  has_submissions_or_grades()
  get_plugin_by_type()
  get_feedback_plugin_by_type()
  get_submission_plugin_by_type()
  load_plugins()
  view()
  add_instance()
  delete_grades()
  delete_instance()
  delete_override()
  delete_all_overrides()
  update_effective_access()
  has_overrides()
  override_exists()
  is_override_calendar_event()
  get_valid_calendar_event_timestart_range()
  reset_userdata()
  update_plugin_instance()
  update_gradebook()
  get_assign_perpage()
  get_admin_config()
  update_calendar()
  update_instance()
  save_intro_draft_files()
  save_editor_draft_files()
  add_plugin_grade_elements()
  add_plugin_settings()
  add_all_plugin_settings()
  plugin_data_preprocessing()
  get_module_name()
  get_module_name_plural()
  has_instance()
  get_default_instance()
  get_instance()
  calculate_properties()
  get_grade_item()
  get_course_context()
  get_course_module()
  get_context()
  get_course()
  count_attachments()
  has_visible_attachments()
  should_provide_intro_attachments()
  display_grade()
  get_submission_info_for_participants()
  list_participants_with_filter_status_and_group()
  get_grading_sort_sql()
  get_submitted_sql()
  list_participants()
  get_participant()
  count_teams()
  count_participants()
  count_submissions_need_grading()
  count_grades()
  count_submissions()
  count_submissions_with_status()
  get_grading_userid_list()
  is_userid_filtered()
  cron()
  notify_grade_modified()
  update_user_flags()
  update_grade()
  view_grant_extension()
  get_submission_group_members()
  get_submission_group_members_who_have_not_submitted()
  get_group_submission()
  view_course_index()
  view_plugin_page()
  get_submission_group()
  get_all_groups()
  view_plugin_content()
  download_rewrite_pluginfile_urls()
  render_editor_content()
  view_savegrading_result()
  view_quickgrading_result()
  view_footer()
  require_view_group_submission()
  require_view_submission()
  require_view_grades()
  can_view_grades()
  can_grade()
  download_submissions()
  add_to_log()
  get_renderer()
  get_user_submission()
  get_submission()
  get_user_flags()
  get_user_grade()
  get_grade()
  view_single_grading_panel()
  view_single_grade_page()
  view_remove_submission_confirm()
  view_reveal_identities_confirm()
  view_return_links()
  view_grading_table()
  view_grader()
  view_grading_page()
  plagiarism_print_disclosure()
  view_notices()
  fullname()
  view_edit_submission_page()
  get_timelimit_panel()
  is_graded()
  can_edit_group_submission()
  can_view_group_submission()
  can_view_submission()
  view_plugin_grading_batch_operation()
  process_grading_batch_operation()
  view_batch_set_workflow_state()
  view_batch_markingallocation()
  check_submit_for_grading()
  get_assign_submission_status_renderable()
  get_assign_feedback_status_renderable()
  get_assign_attempt_history_renderable()
  view_student_summary()
  show_submit_button()
  get_all_grades()
  get_all_submissions()
  get_assign_grading_summary_renderable()
  get_override_data()
  get_duedate()
  get_timelimit()
  get_cutoffdate()
  view_submission_page()
  view_submission_action_bar()
  convert_grade_for_gradebook()
  convert_submission_for_gradebook()
  gradebook_item_update()
  update_team_submission()
  update_submission()
  submissions_open()
  render_area_files()
  can_edit_submission()
  get_shared_group_members()
  get_graders()
  get_notifiable_users()
  format_notification_message_text()
  format_notification_message_html()
  send_assignment_notification()
  send_notification()
  notify_student_submission_copied()
  notify_student_submission_receipt()
  notify_graders()
  submit_for_grading()
  process_submit_other_for_grading()
  process_submit_for_grading()
  save_user_extension()
  process_save_extension()
  process_save_quick_grades()
  reveal_identities()
  process_reveal_identities()
  process_save_grading_options()
  format_grade_for_log()
  format_submission_for_log()
  process_copy_previous_attempt()
  copy_previous_attempt()
  submission_empty()
  new_submission_empty()
  save_submission()
  process_save_submission()
  grading_disabled()
  get_grading_instance()
  add_grade_form_elements()
  add_plugin_submission_elements()
  is_any_feedback_plugin_enabled()
  is_any_submission_plugin_enabled()
  add_submission_form_elements()
  remove_submission()
  revert_to_draft()
  process_remove_submission()
  process_revert_to_draft()
  lock_submission()
  process_set_batch_marking_workflow_state()
  process_set_batch_marking_allocation()
  process_lock_submission()
  unlock_submission()
  process_unlock_submission()
  apply_grade_to_user()
  process_outcomes()
  reopen_submission_if_required()
  save_grade()
  process_save_grade()
  can_upgrade_assignment()
  can_upgrade()
  copy_area_files_for_upgrade()
  process_add_attempt_group()
  process_add_attempt()
  add_attempt()
  get_user_grades_for_gradebook()
  get_uniqueid_for_user()
  allocate_unique_ids()
  get_uniqueid_for_user_static()
  get_user_id_for_uniqueid()
  get_user_id_for_uniqueid_static()
  get_marking_workflow_states_for_current_user()
  show_only_active_users()
  is_active_user()
  is_gradebook_feedback_enabled()
  get_grading_status()
  get_useridlist_key_id()
  get_useridlist_key()
  update_activity_completion_records()
  set_module_viewed()
  add_grade_notices()
  fix_null_grades()
  view_fix_rescaled_null_grades()
  set_most_recent_team_submission()
  get_marking_allocation_filters()
  get_marking_workflow_filters()
  get_filters()
  get_submissionstatement()
  is_time_limit_enabled()
  is_attempt_in_progress()

assign_portfolio_caller:: (14 methods):
  expected_callbackargs()
  __construct()
  load_data()
  prepare_package()
  get_submission_plugin()
  get_sha1()
  expected_time()
  check_permissions()
  display_name()
  base_supported_formats()
  assign_process_group_deleted_in_course()
  move_group_override()
  reorder_group_overrides()
  assign_get_js_module()


Class: assign  - X-Ref

Standard base class for mod_assign (assignment types).

__construct($coursemodulecontext, $coursemodule, $course)   X-Ref
Constructor for the base assign class.

Note: For $coursemodule you can supply a stdclass if you like, but it
will be more efficient to supply a cm_info object.

param: mixed $coursemodulecontext context|null the course module context
param: mixed $coursemodule the current course module if it was already loaded,
param: mixed $course the current course  if it was already loaded,

register_return_link($action, $params)   X-Ref
Set the action and parameters that can be used to return to the current page.

param: string $action The action for the current page
param: array $params An array of name value pairs which form the parameters
return: void

get_return_action()   X-Ref
Return an action that can be used to get back to the current page.

return: string action

show_intro()   X-Ref
Based on the current assignment settings should we display the intro.

return: bool showintro

get_return_params()   X-Ref
Return a list of parameters that can be used to get back to the current page.

return: array params

set_instance(stdClass $data)   X-Ref
Set the submitted form data.

param: stdClass $data The form data (instance)

set_context(context $context)   X-Ref
Set the context.

param: context $context The new context

set_course(stdClass $course)   X-Ref
Set the course data.

param: stdClass $course The course data

set_error_message(string $message)   X-Ref
Set error message.

param: string $message The error message

get_error_messages()   X-Ref
Get error messages.

return: array The array of error messages

get_feedback_plugins()   X-Ref
Get list of feedback plugins installed.

return: array

get_submission_plugins()   X-Ref
Get list of submission plugins installed.

return: array

is_blind_marking()   X-Ref
Is blind marking enabled and reveal identities not set yet?

return: bool

is_hidden_grader()   X-Ref
Is hidden grading enabled?

This just checks the assignment settings. Remember to check
the user has the 'showhiddengrader' capability too

return: bool

has_submissions_or_grades()   X-Ref
Does an assignment have submission(s) or grade(s) already?

return: bool

get_plugin_by_type($subtype, $type)   X-Ref
Get a specific submission plugin by its type.

param: string $subtype assignsubmission | assignfeedback
param: string $type
return: mixed assign_plugin|null

get_feedback_plugin_by_type($type)   X-Ref
Get a feedback plugin by type.

param: string $type - The type of plugin e.g comments
return: mixed assign_feedback_plugin|null

get_submission_plugin_by_type($type)   X-Ref
Get a submission plugin by type.

param: string $type - The type of plugin e.g comments
return: mixed assign_submission_plugin|null

load_plugins($subtype)   X-Ref
Load the plugins from the sub folders under subtype.

param: string $subtype - either submission or feedback
return: array - The sorted list of plugins

view($action='', $args = array()   X-Ref
Display the assignment, used by view.php

The assignment is displayed differently depending on your role,
the settings for the assignment and the status of the assignment.

param: string $action The current action if any.
param: array $args Optional arguments to pass to the view (instead of getting them from GET and POST).
return: string - The page output.

add_instance(stdClass $formdata, $callplugins)   X-Ref
Add this instance to the database.

param: stdClass $formdata The data submitted from the form
param: bool $callplugins This is used to skip the plugin code
return: mixed false if an error occurs or the int id of the new instance

delete_grades()   X-Ref
Delete all grades from the gradebook for this assignment.

return: bool

delete_instance()   X-Ref
Delete this instance from the database.

return: bool false if an error occurs

delete_override($overrideid)   X-Ref
Deletes a assign override from the database and clears any corresponding calendar events

param: int $overrideid The id of the override being deleted
return: bool true on success

delete_all_overrides()   X-Ref
Deletes all assign overrides from the database and clears any corresponding calendar events


update_effective_access($userid)   X-Ref
Updates the assign properties with override information for a user.

Algorithm:  For each assign setting, if there is a matching user-specific override,
then use that otherwise, if there are group-specific overrides, return the most
lenient combination of them.  If neither applies, leave the assign setting unchanged.

param: int $userid The userid.

has_overrides()   X-Ref
Returns whether an assign has any overrides.

return: true if any, false if not

override_exists($userid)   X-Ref
Returns user override

Algorithm:  For each assign setting, if there is a matching user-specific override,
then use that otherwise, if there are group-specific overrides, use the one with the
lowest sort order. If neither applies, leave the assign setting unchanged.

param: int $userid The userid.
return: stdClass The override

is_override_calendar_event(\calendar_event $event)   X-Ref
Check if the given calendar_event is either a user or group override
event.

return: bool

get_valid_calendar_event_timestart_range(\calendar_event $event)   X-Ref
This function calculates the minimum and maximum cutoff values for the timestart of
the given event.

It will return an array with two values, the first being the minimum cutoff value and
the second being the maximum cutoff value. Either or both values can be null, which
indicates there is no minimum or maximum, respectively.

If a cutoff is required then the function must return an array containing the cutoff
timestamp and error string to display to the user if the cutoff value is violated.

A minimum and maximum cutoff return value will look like:
[
[1505704373, 'The due date must be after the sbumission start date'],
[1506741172, 'The due date must be before the cutoff date']
]

If the event does not have a valid timestart range then [false, false] will
be returned.

param: calendar_event $event The calendar event to get the time range for
return: array

reset_userdata($data)   X-Ref
Actual implementation of the reset course functionality, delete all the
assignment submissions for course $data->courseid.

param: stdClass $data the data submitted from the reset course.
return: array status array

update_plugin_instance(assign_plugin $plugin, stdClass $formdata)   X-Ref
Update the settings for a single plugin.

param: assign_plugin $plugin The plugin to update
param: stdClass $formdata The form data
return: bool false if an error occurs

update_gradebook($reset, $coursemoduleid)   X-Ref
Update the gradebook information for this assignment.

param: bool $reset If true, will reset all grades in the gradbook for this assignment
param: int $coursemoduleid This is required because it might not exist in the database yet
return: bool

get_assign_perpage()   X-Ref
Get the marking table page size

return: integer

get_admin_config()   X-Ref
Load and cache the admin config for this module.

return: stdClass the plugin config

update_calendar($coursemoduleid)   X-Ref
Update the calendar entries for this assignment.

param: int $coursemoduleid - Required to pass this in because it might
return: bool

update_instance($formdata)   X-Ref
Update this instance in the database.

param: stdClass $formdata - the data submitted from the form
return: bool false if an error occurs

save_intro_draft_files($formdata)   X-Ref
Save the attachments in the intro description.

param: stdClass $formdata

save_editor_draft_files($formdata)   X-Ref
Save the attachments in the editor description.

param: stdClass $formdata

add_plugin_grade_elements($grade, MoodleQuickForm $mform, stdClass $data, $userid)   X-Ref
Add elements in grading plugin form.

param: mixed $grade stdClass|null
param: MoodleQuickForm $mform
param: stdClass $data
param: int $userid - The userid we are grading
return: void

add_plugin_settings(assign_plugin $plugin, MoodleQuickForm $mform, & $pluginsenabled)   X-Ref
Add one plugins settings to edit plugin form.

param: assign_plugin $plugin The plugin to add the settings from
param: MoodleQuickForm $mform The form to add the configuration settings to.
param: array $pluginsenabled A list of form elements to be added to a group.
return: void

add_all_plugin_settings(MoodleQuickForm $mform)   X-Ref
Add settings to edit plugin form.

param: MoodleQuickForm $mform The form to add the configuration settings to.
return: void

plugin_data_preprocessing(&$defaultvalues)   X-Ref
Allow each plugin an opportunity to update the defaultvalues
passed in to the settings form (needed to set up draft areas for
editor and filemanager elements)

param: array $defaultvalues

get_module_name()   X-Ref
Get the name of the current module.

return: string the module name (Assignment)

get_module_name_plural()   X-Ref
Get the plural name of the current module.

return: string the module name plural (Assignments)

has_instance()   X-Ref
Has this assignment been constructed from an instance?

return: bool

get_default_instance()   X-Ref
Get the settings for the current instance of this assignment.

return: stdClass The settings

get_instance(int $userid = null)   X-Ref
Get the settings for the current instance of this assignment

param: int|null $userid the id of the user to load the assign instance for.
return: stdClass The settings

calculate_properties(\stdClass $record, int $userid)   X-Ref
Calculates and updates various properties based on the specified user.

param: stdClass $record the raw assign record.
param: int $userid the id of the user to calculate the properties for.
return: stdClass a new record having calculated properties.

get_grade_item()   X-Ref
Get the primary grade item for this assign instance.

return: grade_item The grade_item record

get_course_context()   X-Ref
Get the context of the current course.

return: mixed context|null The course context

get_course_module()   X-Ref
Get the current course module.

return: cm_info|null The course module or null if not known

get_context()   X-Ref
Get context module.

return: context

get_course()   X-Ref
Get the current course.

return: mixed stdClass|null The course

count_attachments()   X-Ref
Count the number of intro attachments.

return: int

has_visible_attachments()   X-Ref
Are there any intro attachments to display?

return: boolean

should_provide_intro_attachments(int $userid)   X-Ref
Check if the intro attachments should be provided to the user.

param: int $userid User id.
return: bool

display_grade($grade, $editing, $userid=0, $modified=0)   X-Ref
Return a grade in user-friendly form, whether it's a scale or not.

param: mixed $grade int|null
param: boolean $editing Are we allowing changes to this grade?
param: int $userid The user id the grade belongs to
param: int $modified Timestamp from when the grade was last modified
return: string User-friendly representation of grade

get_submission_info_for_participants($participants)   X-Ref
Get the submission status/grading status for all submissions in this assignment for the
given paticipants.

These statuses match the available filters (requiregrading, submitted, notsubmitted, grantedextension).
If this is a group assignment, group info is also returned.

param: array $participants an associative array where the key is the participant id and
return: array an associative array where the key is the participant id and the value is

list_participants_with_filter_status_and_group($currentgroup, $tablesort = false)   X-Ref
Get the submission status/grading status for all submissions in this assignment.
These statuses match the available filters (requiregrading, submitted, notsubmitted, grantedextension).
If this is a group assignment, group info is also returned.

param: int $currentgroup
param: boolean $tablesort Apply current user table sorting preferences.
return: array List of user records with extra fields 'submitted', 'notsubmitted', 'requiregrading', 'grantedextension',

get_grading_sort_sql()   X-Ref
Return a valid order by segment for list_participants that matches
the sorting of the current grading table. Not every field is supported,
we are only concerned with a list of users so we can't search on anything
that is not part of the user information (like grading statud or last modified stuff).

return: string Order by clause for list_participants

get_submitted_sql($group = 0)   X-Ref
Returns array with sql code and parameters returning all ids of users who have submitted an assignment.

param: int $group The group that the query is for.
return: array list($sql, $params)

list_participants($currentgroup, $idsonly, $tablesort = false)   X-Ref
Load a list of users enrolled in the current course with the specified permission and group.
0 for no group.
Apply any current sort filters from the grading table.

param: int $currentgroup
param: bool $idsonly
param: bool $tablesort
return: array List of user records

get_participant($userid)   X-Ref
Load a user if they are enrolled in the current course. Populated with submission
status for this assignment.

param: int $userid
return: null|stdClass user record

count_teams($activitygroup = 0)   X-Ref
Load a count of valid teams for this assignment.

param: int $activitygroup Activity active group
return: int number of valid teams

count_participants($currentgroup)   X-Ref
Load a count of active users enrolled in the current course with the specified permission and group.
0 for no group.

param: int $currentgroup
return: int number of matching users

count_submissions_need_grading($currentgroup = null)   X-Ref
Load a count of active users submissions in the current module that require grading
This means the submission modification time is more recent than the
grading modification time and the status is SUBMITTED.

param: mixed $currentgroup int|null the group for counting (if null the function will determine it)
return: int number of matching submissions

count_grades()   X-Ref
Load a count of grades.

return: int number of grades

count_submissions($includenew = false)   X-Ref
Load a count of submissions.

param: bool $includenew When true, also counts the submissions with status 'new'.
return: int number of submissions

count_submissions_with_status($status, $currentgroup = null)   X-Ref
Load a count of submissions with a specified status.

param: string $status The submission status - should match one of the constants
param: mixed $currentgroup int|null the group for counting (if null the function will determine it)
return: int number of matching submissions

get_grading_userid_list($cached = false, $useridlistid = '')   X-Ref
Utility function to get the userid for every row in the grading table
so the order can be frozen while we iterate it.

param: boolean $cached If true, the cached list from the session could be returned.
param: string $useridlistid String value used for caching the participant list.
return: array An array of userids

is_userid_filtered($userid)   X-Ref
Is user id filtered by user filters and table preferences.

param: int $userid User id that needs to be checked.
return: bool

cron()   X-Ref
Finds all assignment notifications that have yet to be mailed out, and mails them.

Cron function to be run periodically according to the moodle cron.

return: bool

notify_grade_modified($grade, $mailedoverride = false)   X-Ref
Mark in the database that this grade record should have an update notification sent by cron.

param: stdClass $grade a grade record keyed on id
param: bool $mailedoverride when true, flag notification to be sent again.
return: bool true for success

update_user_flags($flags)   X-Ref
Update user flags for this user in this assignment.

param: stdClass $flags a flags record keyed on id
return: bool true for success

update_grade($grade, $reopenattempt = false)   X-Ref
Update a grade in the grade table for the assignment and in the gradebook.

param: stdClass $grade a grade record keyed on id
param: bool $reopenattempt If the attempt reopen method is manual, allow another attempt at this assignment.
return: bool true for success

view_grant_extension($mform)   X-Ref
View the grant extension date page.

Uses url parameters 'userid'
or from parameter 'selectedusers'

param: moodleform $mform - Used for validation of the submitted data
return: string

get_submission_group_members($groupid, $onlyids, $excludesuspended = false)   X-Ref
Get a list of the users in the same group as this user.

param: int $groupid The id of the group whose members we want or 0 for the default group
param: bool $onlyids Whether to retrieve only the user id's
param: bool $excludesuspended Whether to exclude suspended users
return: array The users (possibly id's only)

get_submission_group_members_who_have_not_submitted($groupid, $onlyids)   X-Ref
Get a list of the users in the same group as this user that have not submitted the assignment.

param: int $groupid The id of the group whose members we want or 0 for the default group
param: bool $onlyids Whether to retrieve only the user id's
return: array The users (possibly id's only)

get_group_submission($userid, $groupid, $create, $attemptnumber=-1)   X-Ref
Load the group submission object for a particular user, optionally creating it if required.

param: int $userid The id of the user whose submission we want
param: int $groupid The id of the group for this user - may be 0 in which
param: bool $create If set to true a new submission object will be created in the database
param: int $attemptnumber - -1 means the latest attempt
return: stdClass|false The submission

view_course_index()   X-Ref
View a summary listing of all assignments in the current course.

return: string

view_plugin_page()   X-Ref
View a page rendered by a plugin.

Uses url parameters 'pluginaction', 'pluginsubtype', 'plugin', and 'id'.

return: string

get_submission_group($userid)   X-Ref
This is used for team assignments to get the group for the specified user.
If the user is a member of multiple or no groups this will return false

param: int $userid The id of the user whose submission we want
return: mixed The group or false

get_all_groups($userid)   X-Ref
Gets all groups the user is a member of.

param: int $userid Teh id of the user who's groups we are checking
return: array The group objects

view_plugin_content($pluginsubtype)   X-Ref
Display the submission that is used by a plugin.

Uses url parameters 'sid', 'gid' and 'plugin'.

param: string $pluginsubtype
return: string

download_rewrite_pluginfile_urls($text, $user, $plugin)   X-Ref
Rewrite plugin file urls so they resolve correctly in an exported zip.

param: string $text - The replacement text
param: stdClass $user - The user record
param: assign_plugin $plugin - The assignment plugin

render_editor_content($filearea, $submissionid, $plugintype, $editor, $component, $shortentext = false)   X-Ref
Render the content in editor that is often used by plugin.

param: string $filearea
param: int $submissionid
param: string $plugintype
param: string $editor
param: string $component
param: bool $shortentext Whether to shorten the text content.
return: string

view_savegrading_result($message)   X-Ref
Display a continue page after grading.

param: string $message - The message to display.
return: string

view_quickgrading_result($message)   X-Ref
Display a continue page after quickgrading.

param: string $message - The message to display.
return: string

view_footer()   X-Ref
Display the page footer.

return: string

require_view_group_submission($groupid)   X-Ref
Throw an error if the permissions to view this users' group submission are missing.

param: int $groupid Group id.

require_view_submission($userid)   X-Ref
Throw an error if the permissions to view this users submission are missing.

return: none

require_view_grades()   X-Ref
Throw an error if the permissions to view grades in this assignment are missing.

return: none

can_view_grades($groupid = null)   X-Ref
Does this user have view grade or grade permission for this assignment?

param: mixed $groupid int|null when is set to a value, use this group instead calculating it
return: bool

can_grade($user = null)   X-Ref
Does this user have grade permission for this assignment?

param: int|stdClass $user The object or id of the user who will do the editing (default to current user).
return: bool

download_submissions($userids = null)   X-Ref
Download a zip file of all assignment submissions.

param: array|null $userids Array of user ids to download assignment submissions in a zip file
return: string - If an error occurs, this will contain the error page.

add_to_log()   X-Ref


get_renderer()   X-Ref
Lazy load the page renderer and expose the renderer to plugins.

return: assign_renderer

get_user_submission($userid, $create, $attemptnumber=-1)   X-Ref
Load the submission object for a particular user, optionally creating it if required.

For team assignments there are 2 submissions - the student submission and the team submission
All files are associated with the team submission but the status of the students contribution is
recorded separately.

param: int $userid The id of the user whose submission we want or 0 in which case USER->id is used
param: bool $create If set to true a new submission object will be created in the database with the status set to "new".
param: int $attemptnumber - -1 means the latest attempt
return: stdClass|false The submission

get_submission($submissionid)   X-Ref
Load the submission object from it's id.

param: int $submissionid The id of the submission we want
return: stdClass The submission

get_user_flags($userid, $create)   X-Ref
This will retrieve a user flags object from the db optionally creating it if required.
The user flags was split from the user_grades table in 2.5.

param: int $userid The user we are getting the flags for.
param: bool $create If true the flags record will be created if it does not exist
return: stdClass The flags record

get_user_grade($userid, $create, $attemptnumber=-1)   X-Ref
This will retrieve a grade object from the db, optionally creating it if required.

param: int $userid The user we are grading
param: bool $create If true the grade will be created if it does not exist
param: int $attemptnumber The attempt number to retrieve the grade for. -1 means the latest submission.
return: stdClass The grade record

get_grade($gradeid)   X-Ref
This will retrieve a grade object from the db.

param: int $gradeid The id of the grade
return: stdClass The grade record

view_single_grading_panel($args)   X-Ref
Print the grading page for a single user submission.

param: array $args Optional args array (better than pulling args from _GET and _POST)
return: string

view_single_grade_page($mform)   X-Ref
Print the grading page for a single user submission.

param: moodleform $mform
return: string

view_remove_submission_confirm()   X-Ref
Show a confirmation page to make sure they want to remove submission data.

return: string

view_reveal_identities_confirm()   X-Ref
Show a confirmation page to make sure they want to release student identities.

return: string

view_return_links()   X-Ref
View a link to go back to the previous page. Uses url parameters returnaction and returnparams.

return: string

view_grading_table()   X-Ref
View the grading table of all submissions for this assignment.

return: string

view_grader()   X-Ref
View entire grader app.

return: string

view_grading_page()   X-Ref
View entire grading page.

return: string

plagiarism_print_disclosure()   X-Ref
Capture the output of the plagiarism plugins disclosures and return it as a string.

return: string

view_notices($title, $notices)   X-Ref
Message for students when assignment submissions have been closed.

param: string $title The page title
param: array $notices The array of notices to show.
return: string

fullname($user)   X-Ref
Get the name for a user - hiding their real name if blind marking is on.

param: stdClass $user The user record as required by fullname()
return: string The name.

view_edit_submission_page($mform, $notices)   X-Ref
View edit submissions page.

param: moodleform $mform
param: array $notices A list of notices to display at the top of the
return: string The page output.

get_timelimit_panel(stdClass $submission)   X-Ref
Get the time limit panel object for this submission attempt.

param: stdClass $submission assign submission.
return: string the panel output.

is_graded($userid)   X-Ref
See if this assignment has a grade yet.

param: int $userid
return: bool

can_edit_group_submission($groupid)   X-Ref
Perform an access check to see if the current $USER can edit this group submission.

param: int $groupid
return: bool

can_view_group_submission($groupid)   X-Ref
Perform an access check to see if the current $USER can view this group submission.

param: int $groupid
return: bool

can_view_submission($userid)   X-Ref
Perform an access check to see if the current $USER can view this users submission.

param: int $userid
return: bool

view_plugin_grading_batch_operation($mform)   X-Ref
Allows the plugin to show a batch grading operation page.

param: moodleform $mform
return: none

process_grading_batch_operation(& $mform)   X-Ref
Ask the user to confirm they want to perform this batch operation

param: moodleform $mform Set to a grading batch operations form
return: string - the page to view after processing these actions

view_batch_set_workflow_state($mform)   X-Ref
Shows a form that allows the workflow state for selected submissions to be changed.

param: moodleform $mform Set to a grading batch operations form
return: string - the page to view after processing these actions

view_batch_markingallocation($mform)   X-Ref
Shows a form that allows the allocated marker for selected submissions to be changed.

param: moodleform $mform Set to a grading batch operations form
return: string - the page to view after processing these actions

check_submit_for_grading($mform)   X-Ref
Ask the user to confirm they want to submit their work for grading.

param: moodleform $mform - null unless form validation has failed
return: string

get_assign_submission_status_renderable($user, $showlinks)   X-Ref
Creates an assign_submission_status renderable.

param: stdClass $user the user to get the report for
param: bool $showlinks return plain text or links to the profile
return: assign_submission_status renderable object

get_assign_feedback_status_renderable($user)   X-Ref
Creates an assign_feedback_status renderable.

param: stdClass $user the user to get the report for
return: assign_feedback_status renderable object

get_assign_attempt_history_renderable($user)   X-Ref
Creates an assign_attempt_history renderable.

param: stdClass $user the user to get the report for
return: assign_attempt_history renderable object

view_student_summary($user, $showlinks)   X-Ref
Print 2 tables of information with no action links -
the submission summary and the grading summary.

param: stdClass $user the user to print the report for
param: bool $showlinks - Return plain text or links to the profile
return: string - the html summary

show_submit_button($submission = null, $teamsubmission = null, $userid = null)   X-Ref
Returns true if the submit subsission button should be shown to the user.

param: stdClass $submission The users own submission record.
param: stdClass $teamsubmission The users team submission record if there is one
param: int $userid The user
return: bool

get_all_grades($userid)   X-Ref
Get the grades for all previous attempts.
For each grade - the grader is a full user record,
and gradefordisplay is added (rendered from grading manager).

param: int $userid If not set, $USER->id will be used.
return: array $grades All grade records for this user.

get_all_submissions($userid)   X-Ref
Get the submissions for all previous attempts.

param: int $userid If not set, $USER->id will be used.
return: array $submissions All submission records for this user (or group).

get_assign_grading_summary_renderable($activitygroup = null)   X-Ref
Creates an assign_grading_summary renderable.

param: mixed $activitygroup int|null the group for calculating the grading summary (if null the function will determine it)
return: assign_grading_summary renderable object

get_override_data(int $activitygroup)   X-Ref
Helper function to allow up to fetch the group overrides via one query as opposed to many calls.

param: int $activitygroup The group we want to check the overrides of
return: mixed Can return either a fetched DB object, local object or false

get_duedate($activitygroup = null)   X-Ref
Return group override duedate.

param: int $activitygroup Activity active group
return: int $duedate

get_timelimit(?int $activitygroup = null)   X-Ref
Return group override timelimit.

param: null|int $activitygroup Activity active group
return: int $timelimit

get_cutoffdate(?int $activitygroup = null)   X-Ref
Return group override cutoffdate.

param: null|int $activitygroup Activity active group
return: int $cutoffdate

view_submission_page()   X-Ref
View submissions page (contains details of current submission).

return: string

view_submission_action_bar(stdClass $instance, stdClass $user)   X-Ref
The action bar displayed in the submissions page.

param: stdClass $instance The settings for the current instance of this assignment
param: stdClass $user The user to print the action bar for
return: string

convert_grade_for_gradebook(stdClass $grade)   X-Ref
Convert the final raw grade(s) in the grading table for the gradebook.

param: stdClass $grade
return: array

convert_submission_for_gradebook(stdClass $submission)   X-Ref
Convert submission details for the gradebook.

param: stdClass $submission
return: array

gradebook_item_update($submission=null, $grade=null)   X-Ref
Update grades in the gradebook.

param: mixed $submission stdClass|null
param: mixed $grade stdClass|null
return: bool

update_team_submission(stdClass $submission, $userid, $updatetime)   X-Ref
Update team submission.

param: stdClass $submission
param: int $userid
param: bool $updatetime
return: bool

update_submission(stdClass $submission, $userid, $updatetime, $teamsubmission)   X-Ref
Update grades in the gradebook based on submission time.

param: stdClass $submission
param: int $userid
param: bool $updatetime
param: bool $teamsubmission
return: bool

submissions_open($userid = 0,$skipenrolled = false,$submission = false,$flags = false,$gradinginfo = false)   X-Ref
Is this assignment open for submissions?

Check the due date,
prevent late submissions,
has this person already submitted,
is the assignment locked?

param: int $userid - Optional userid so we can see if a different user can submit
param: bool $skipenrolled - Skip enrollment checks (because they have been done already)
param: stdClass $submission - Pre-fetched submission record (or false to fetch it)
param: stdClass $flags - Pre-fetched user flags record (or false to fetch it)
param: stdClass $gradinginfo - Pre-fetched user gradinginfo record (or false to fetch it)
return: bool

render_area_files($component, $area, $submissionid)   X-Ref
Render the files in file area.

param: string $component
param: string $area
param: int $submissionid
return: string

can_edit_submission($userid, $graderid = 0)   X-Ref
Capability check to make sure this grader can edit this submission.

param: int $userid - The user whose submission is to be edited
param: int $graderid (optional) - The user who will do the editing (default to $USER->id).
return: bool

get_shared_group_members($cm, $userid)   X-Ref
Returns IDs of the users who share group membership with the specified user.

param: stdClass|cm_info $cm Course-module
param: int $userid User ID
return: array An array of ID of users.

get_graders($userid)   X-Ref
Returns a list of teachers that should be grading given submission.

param: int $userid The submission to grade
return: array

get_notifiable_users($userid)   X-Ref
Returns a list of users that should receive notification about given submission.

param: int $userid The submission to grade
return: array

format_notification_message_text($messagetype,$info,$course,$context,$modulename,$assignmentname)   X-Ref
Format a notification for plain text.

param: string $messagetype
param: stdClass $info
param: stdClass $course
param: stdClass $context
param: string $modulename
param: string $assignmentname

format_notification_message_html($messagetype,$info,$course,$context,$modulename,$coursemodule,$assignmentname)   X-Ref
Format a notification for HTML.

param: string $messagetype
param: stdClass $info
param: stdClass $course
param: stdClass $context
param: string $modulename
param: stdClass $coursemodule
param: string $assignmentname

send_assignment_notification($userfrom,$userto,$messagetype,$eventtype,$updatetime,$coursemodule,$context,$course,$modulename,$assignmentname,$blindmarking,$uniqueidforuser)   X-Ref
Message someone about something (static so it can be called from cron).

param: stdClass $userfrom
param: stdClass $userto
param: string $messagetype
param: string $eventtype
param: int $updatetime
param: stdClass $coursemodule
param: stdClass $context
param: stdClass $course
param: string $modulename
param: string $assignmentname
param: bool $blindmarking
param: int $uniqueidforuser
return: void

send_notification($userfrom, $userto, $messagetype, $eventtype, $updatetime)   X-Ref
Message someone about something.

param: stdClass $userfrom
param: stdClass $userto
param: string $messagetype
param: string $eventtype
param: int $updatetime
return: void

notify_student_submission_copied(stdClass $submission)   X-Ref
Notify student upon successful submission copy.

param: stdClass $submission
return: void

notify_student_submission_receipt(stdClass $submission)   X-Ref
Notify student upon successful submission.

param: stdClass $submission
return: void

notify_graders(stdClass $submission)   X-Ref
Send notifications to graders upon student submissions.

param: stdClass $submission
return: void

submit_for_grading($data, $notices)   X-Ref
Submit a submission for grading.

param: stdClass $data - The form data
param: array $notices - List of error messages to display on an error condition.
return: bool Return false if the submission was not submitted.

process_submit_other_for_grading($mform, $notices)   X-Ref
A students submission is submitted for grading by a teacher.

return: bool

process_submit_for_grading($mform, $notices)   X-Ref
Assignment submission is processed before grading.

param: moodleform|null $mform If validation failed when submitting this form - this is the moodleform.
return: bool Return false if the validation fails. This affects which page is displayed next.

save_user_extension($userid, $extensionduedate)   X-Ref
Save the extension date for a single user.

param: int $userid The user id
param: mixed $extensionduedate Either an integer date or null
return: boolean

process_save_extension(& $mform)   X-Ref
Save extension date.

param: moodleform $mform The submitted form
return: boolean

process_save_quick_grades()   X-Ref
Save quick grades.

return: string The result of the save operation

reveal_identities()   X-Ref
Reveal student identities to markers (and the gradebook).

return: void

process_reveal_identities()   X-Ref
Reveal student identities to markers (and the gradebook).

return: void

process_save_grading_options()   X-Ref
Save grading options.

return: void

format_grade_for_log()   X-Ref


format_submission_for_log()   X-Ref


process_copy_previous_attempt(&$notices)   X-Ref
Require a valid sess key and then call copy_previous_attempt.

param: array $notices Any error messages that should be shown
return: bool

copy_previous_attempt(&$notices)   X-Ref
Copy the current assignment submission from the last submitted attempt.

param: array $notices Any error messages that should be shown
return: bool

submission_empty($submission)   X-Ref
Determine if the current submission is empty or not.

param: submission $submission the students submission record to check.
return: bool

new_submission_empty($data)   X-Ref
Determine if a new submission is empty or not

param: stdClass $data Submission data
return: bool

save_submission(stdClass $data, & $notices)   X-Ref
Save assignment submission for the current user.

param: stdClass $data
param: array $notices Any error messages that should be shown
return: bool

process_save_submission(&$mform, &$notices)   X-Ref
Save assignment submission.

param: moodleform $mform
param: array $notices Any error messages that should be shown
return: bool

grading_disabled($userid, $checkworkflow = true, $gradinginfo = null)   X-Ref
Determine if this users grade can be edited.

param: int $userid - The student userid
param: bool $checkworkflow - whether to include a check for the workflow state.
param: stdClass $gradinginfo - optional, allow gradinginfo to be passed for performance.
return: bool $gradingdisabled

get_grading_instance($userid, $grade, $gradingdisabled)   X-Ref
Get an instance of a grading form if advanced grading is enabled.
This is specific to the assignment, marker and student.

param: int $userid - The student userid
param: stdClass|false $grade - The grade record
param: bool $gradingdisabled
return: mixed gradingform_instance|null $gradinginstance

add_grade_form_elements(MoodleQuickForm $mform, stdClass $data, $params)   X-Ref
Add elements to grade form.

param: MoodleQuickForm $mform
param: stdClass $data
param: array $params
return: void

add_plugin_submission_elements($submission,MoodleQuickForm $mform,stdClass $data,$userid)   X-Ref
Add elements in submission plugin form.

param: mixed $submission stdClass|null
param: MoodleQuickForm $mform
param: stdClass $data
param: int $userid The current userid (same as $USER->id)
return: void

is_any_feedback_plugin_enabled()   X-Ref
Check if feedback plugins installed are enabled.

return: bool

is_any_submission_plugin_enabled()   X-Ref
Check if submission plugins installed are enabled.

return: bool

add_submission_form_elements(MoodleQuickForm $mform, stdClass $data)   X-Ref
Add elements to submission form.

param: MoodleQuickForm $mform
param: stdClass $data
return: void

remove_submission($userid)   X-Ref
Remove any data from the current submission.

param: int $userid
return: boolean

revert_to_draft($userid)   X-Ref
Revert to draft.

param: int $userid
return: boolean

process_remove_submission($userid = 0)   X-Ref
Remove the current submission.

param: int $userid
return: boolean

process_revert_to_draft($userid = 0)   X-Ref
Revert to draft.
Uses url parameter userid if userid not supplied as a parameter.

param: int $userid
return: boolean

lock_submission($userid)   X-Ref
Prevent student updates to this submission

param: int $userid
return: bool

process_set_batch_marking_workflow_state()   X-Ref
Set the workflow state for multiple users

return: void

process_set_batch_marking_allocation()   X-Ref
Set the marking allocation for multiple users

return: void

process_lock_submission($userid = 0)   X-Ref
Prevent student updates to this submission.
Uses url parameter userid.

param: int $userid
return: void

unlock_submission($userid)   X-Ref
Unlock the student submission.

param: int $userid
return: bool

process_unlock_submission($userid = 0)   X-Ref
Unlock the student submission.
Uses url parameter userid.

param: int $userid
return: bool

apply_grade_to_user($formdata, $userid, $attemptnumber)   X-Ref
Apply a grade from a grading form to a user (may be called multiple times for a group submission).

param: stdClass $formdata - the data from the form
param: int $userid - the user to apply the grade to
param: int $attemptnumber - The attempt number to apply the grade to.
return: void

process_outcomes($userid, $formdata, $sourceuserid = null)   X-Ref
Save outcomes submitted from grading form.

param: int $userid
param: stdClass $formdata
param: int $sourceuserid The user ID under which the outcome data is accessible. This is relevant

reopen_submission_if_required($userid, $submission, $addattempt)   X-Ref
If the requirements are met - reopen the submission for another attempt.
Only call this function when grading the latest attempt.

param: int $userid The userid.
param: stdClass $submission The submission (may be a group submission).
param: bool $addattempt - True if the "allow another attempt" checkbox was checked.
return: bool - true if another attempt was added.

save_grade($userid, $data)   X-Ref
Save grade update.

param: int $userid
param: stdClass $data
return: bool - was the grade saved

process_save_grade(&$mform)   X-Ref
Save grade.

param: moodleform $mform
return: bool - was the grade saved

can_upgrade_assignment($type, $version)   X-Ref
This function is a static wrapper around can_upgrade.

param: string $type The plugin type
param: int $version The plugin version
return: bool

can_upgrade($type, $version)   X-Ref
This function returns true if it can upgrade an assignment from the 2.2 module.

param: string $type The plugin type
param: int $version The plugin version
return: bool

copy_area_files_for_upgrade($oldcontextid,$oldcomponent,$oldfilearea,$olditemid,$newcontextid,$newcomponent,$newfilearea,$newitemid)   X-Ref
Copy all the files from the old assignment files area to the new one.
This is used by the plugin upgrade code.

param: int $oldcontextid The old assignment context id
param: int $oldcomponent The old assignment component ('assignment')
param: int $oldfilearea The old assignment filearea ('submissions')
param: int $olditemid The old submissionid (can be null e.g. intro)
param: int $newcontextid The new assignment context id
param: int $newcomponent The new assignment component ('assignment')
param: int $newfilearea The new assignment filearea ('submissions')
param: int $newitemid The new submissionid (can be null e.g. intro)
return: int The number of files copied

process_add_attempt_group($useridlist)   X-Ref
Add a new attempt for each user in the list - but reopen each group assignment
at most 1 time.

param: array $useridlist Array of userids to reopen.
return: bool

process_add_attempt($userid)   X-Ref
Check for a sess key and then call add_attempt.

param: int $userid int The user to add the attempt for
return: bool - true if successful.

add_attempt($userid)   X-Ref
Add a new attempt for a user.

param: int $userid int The user to add the attempt for
return: bool - true if successful.

get_user_grades_for_gradebook($userid)   X-Ref
Get an upto date list of user grades and feedback for the gradebook.

param: int $userid int or 0 for all users
return: array of grade data formated for the gradebook api

get_uniqueid_for_user($userid)   X-Ref
Call the static version of this function

param: int $userid The userid to lookup
return: int The unique id

allocate_unique_ids($assignid)   X-Ref
Foreach participant in the course - assign them a random id.

param: int $assignid The assignid to lookup

get_uniqueid_for_user_static($assignid, $userid)   X-Ref
Lookup this user id and return the unique id for this assignment.

param: int $assignid The assignment id
param: int $userid The userid to lookup
return: int The unique id

get_user_id_for_uniqueid($uniqueid)   X-Ref
Call the static version of this function.

param: int $uniqueid The uniqueid to lookup
return: int The user id or false if they don't exist

get_user_id_for_uniqueid_static($assignid, $uniqueid)   X-Ref
Lookup this unique id and return the user id for this assignment.

param: int $assignid The id of the assignment this user mapping is in
param: int $uniqueid The uniqueid to lookup
return: int The user id or false if they don't exist

get_marking_workflow_states_for_current_user()   X-Ref
Get the list of marking_workflow states the current user has permission to transition a grade to.

return: array of state => description

show_only_active_users()   X-Ref
Check is only active users in course should be shown.

return: bool true if only active users should be shown.

is_active_user($userid)   X-Ref
Return true is user is active user in course else false

param: int $userid
return: bool true is user is active in course.

is_gradebook_feedback_enabled()   X-Ref
Returns true if gradebook feedback plugin is enabled

return: bool true if gradebook feedback plugin is enabled and visible else false.

get_grading_status($userid)   X-Ref
Returns the grading status.

param: int $userid the user id
return: string returns the grading status

get_useridlist_key_id()   X-Ref
The id used to uniquily identify the cache for this instance of the assign object.

return: string

get_useridlist_key($id = null)   X-Ref
Generates the key that should be used for an entry in the useridlist cache.

param: string $id Generate a key for this instance (optional)
return: string The key for the id, or new entry if no $id is passed.

update_activity_completion_records($teamsubmission,$requireallteammemberssubmit,$submission,$userid,$complete,$completion)   X-Ref
Updates and creates the completion records in mdl_course_modules_completion.

param: int $teamsubmission value of 0 or 1 to indicate whether this is a group activity
param: int $requireallteammemberssubmit value of 0 or 1 to indicate whether all group members must click Submit
param: obj $submission the submission
param: int $userid the user id
param: int $complete
param: obj $completion
return: null

set_module_viewed()   X-Ref
Update the module completion status (set it viewed) and trigger module viewed event.


add_grade_notices()   X-Ref
Checks for any grade notices, and adds notifications. Will display on assignment main page and grading table.

return: void The notifications API will render the notifications at the appropriate part of the page.

fix_null_grades()   X-Ref
View fix rescaled null grades.

return: bool True if null all grades are now fixed.

view_fix_rescaled_null_grades()   X-Ref
View fix rescaled null grades.

return: void The notifications API will render the notifications at the appropriate part of the page.

set_most_recent_team_submission($submission)   X-Ref
Set the most recent submission for the team.
The most recent team submission is used to determine if another attempt should be created when allowing another
attempt on a group assignment, and whether the gradebook should be updated.

param: stdClass $submission The most recent submission of the group.

get_marking_allocation_filters($export = false)   X-Ref
Return array of valid grading allocation filters for the grading interface.

param: boolean $export Export the list of filters for a template.
return: array

get_marking_workflow_filters($export = false)   X-Ref
Return array of valid grading workflow filters for the grading interface.

param: boolean $export Export the list of filters for a template.
return: array

get_filters()   X-Ref
Return array of valid search filters for the grading interface.

return: array

get_submissionstatement($adminconfig, $instance, $context)   X-Ref
Get the correct submission statement depending on single submisison, team submission or team submission
where all team memebers must submit.

param: stdClass $adminconfig
param: stdClass $instance
param: context $context
return: string

is_time_limit_enabled(?int $userid = null)   X-Ref
Check if time limit for assignment enabled and set up.

param: int|null $userid User ID. If null, use global user.
return: bool

is_attempt_in_progress(?int $userid = null, int $groupid = 0, int $attemptnumber = -1)   X-Ref
Check if an assignment submission is already started and not yet submitted.

param: int|null $userid User ID. If null, use global user.
param: int $groupid Group ID. If 0, use user id to determine group.
param: int $attemptnumber Attempt number. If -1, check latest submission.
return: bool

Class: assign_portfolio_caller  - X-Ref

Portfolio caller class for mod_assign.

expected_callbackargs()   X-Ref
Callback arg for a single file export.


__construct($callbackargs)   X-Ref
The constructor.

param: array $callbackargs

load_data()   X-Ref
Load data needed for the portfolio export.

If the assignment type implements portfolio_load_data(), the processing is delegated
to it. Otherwise, the caller must provide either fileid (to export single file) or
submissionid and filearea (to export all data attached to the given submission file area)
via callback arguments.


prepare_package()   X-Ref
Prepares the package up before control is passed to the portfolio plugin.

return: mixed

get_submission_plugin()   X-Ref
Fetch the plugin by its type.

return: assign_submission_plugin

get_sha1()   X-Ref
Calculate a sha1 has of either a single file or a list
of files based on the data set by load_data.

return: string

expected_time()   X-Ref
Calculate the time to transfer either a single file or a list
of files based on the data set by load_data.

return: int

check_permissions()   X-Ref
Checking the permissions.

return: bool

display_name()   X-Ref
Display a module name.

return: string

base_supported_formats()   X-Ref
Return array of formats supported by this portfolio call back.

return: array

assign_process_group_deleted_in_course($courseid, $groupid = null)   X-Ref
Logic to happen when a/some group(s) has/have been deleted in a course.

param: int $courseid The course ID.
param: int $groupid The group id if it is known
return: void

move_group_override($id, $move, $assignid)   X-Ref
Change the sort order of an override

param: int $id of the override
param: string $move direction of move
param: int $assignid of the assignment
return: bool success of operation

reorder_group_overrides($assignid)   X-Ref
Reorder the overrides starting at the override at the given startorder.

param: int $assignid of the assigment

assign_get_js_module()   X-Ref
Get the information about the standard assign JavaScript module.

return: array a standard jsmodule structure.