Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
assign Class Reference

Standard base class for mod_assign (assignment types). More...

Public Member Functions

 __construct ($coursemodulecontext, $coursemodule, $course)
 Constructor for the base assign class.
 
 add_all_plugin_settings (MoodleQuickForm $mform)
 Add settings to edit plugin form.
 
 add_grade_form_elements (MoodleQuickForm $mform, stdClass $data, $params)
 Add elements to grade form.
 
 add_instance (stdClass $formdata, $callplugins)
 Add this instance to the database.
 
 add_submission_form_elements (MoodleQuickForm $mform, stdClass $data)
 Add elements to submission form.
 
 add_to_log ($action='', $info='', $url='', $return=false)
 Util function to add a message to the log.
 
 can_edit_group_submission ($groupid)
 Perform an access check to see if the current $USER can edit this group submission.
 
 can_edit_submission ($userid, $graderid=0)
 Capability check to make sure this grader can edit this submission.
 
 can_grade ($user=null)
 Does this user have grade permission for this assignment?
 
 can_upgrade ($type, $version)
 This function returns true if it can upgrade an assignment from the 2.2 module.
 
 can_view_grades ($groupid=null)
 Does this user have view grade or grade permission for this assignment?
 
 can_view_group_submission ($groupid)
 Perform an access check to see if the current $USER can view this group submission.
 
 can_view_submission ($userid)
 Perform an access check to see if the current $USER can view this users submission.
 
 copy_area_files_for_upgrade ($oldcontextid, $oldcomponent, $oldfilearea, $olditemid, $newcontextid, $newcomponent, $newfilearea, $newitemid)
 Copy all the files from the old assignment files area to the new one.
 
 copy_previous_attempt (&$notices)
 Copy the current assignment submission from the last submitted attempt.
 
 count_grades ()
 Load a count of grades.
 
 count_participants ($currentgroup)
 Load a count of active users enrolled in the current course with the specified permission and group.
 
 count_submissions ($includenew=false)
 Load a count of submissions.
 
 count_submissions_need_grading ($currentgroup=null)
 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.
 
 count_submissions_with_status ($status, $currentgroup=null)
 Load a count of submissions with a specified status.
 
 count_teams ($activitygroup=0)
 Load a count of valid teams for this assignment.
 
 delete_all_overrides ()
 Deletes all assign overrides from the database and clears any corresponding calendar events.
 
 delete_instance ()
 Delete this instance from the database.
 
 delete_override ($overrideid)
 Deletes a assign override from the database and clears any corresponding calendar events.
 
 display_grade ($grade, $editing, $userid=0, $modified=0)
 Return a grade in user-friendly form, whether it's a scale or not.
 
 download_rewrite_pluginfile_urls ($text, $user, $plugin)
 Rewrite plugin file urls so they resolve correctly in an exported zip.
 
 format_grade_for_log (stdClass $grade)
 Take a grade object and print a short summary for the log file.
 
 format_submission_for_log (stdClass $submission)
 Take a submission object and print a short summary for the log file.
 
 fullname ($user)
 Get the name for a user - hiding their real name if blind marking is on.
 
 get_admin_config ()
 Load and cache the admin config for this module.
 
 get_all_groups ($userid)
 Gets all groups the user is a member of.
 
 get_all_submissions ($userid)
 Get the submissions for all previous attempts.
 
 get_assign_attempt_history_renderable ($user)
 Creates an assign_attempt_history renderable.
 
 get_assign_feedback_status_renderable ($user)
 Creates an assign_feedback_status renderable.
 
 get_assign_grading_summary_renderable ($activitygroup=null)
 Creates an assign_grading_summary renderable.
 
 get_assign_perpage ()
 Get the marking table page size.
 
 get_assign_submission_status_renderable ($user, $showlinks)
 Creates an assign_submission_status renderable.
 
 get_context ()
 Get context module.
 
 get_course ()
 Get the current course.
 
 get_course_context ()
 Get the context of the current course.
 
 get_course_module ()
 Get the current course module.
 
 get_default_instance ()
 Get the settings for the current instance of this assignment.
 
 get_feedback_plugin_by_type ($type)
 Get a feedback plugin by type.
 
 get_feedback_plugins ()
 Get list of feedback plugins installed.
 
 get_filters ()
 Return array of valid search filters for the grading interface.
 
 get_grade_item ()
 Get the primary grade item for this assign instance.
 
 get_grading_status ($userid)
 Returns the grading status.
 
 get_group_submission ($userid, $groupid, $create, $attemptnumber=-1)
 Load the group submission object for a particular user, optionally creating it if required.
 
 get_instance (int $userid=null)
 Get the settings for the current instance of this assignment.
 
 get_marking_allocation_filters ($export=false)
 Return array of valid grading allocation filters for the grading interface.
 
 get_marking_workflow_filters ($export=false)
 Return array of valid grading workflow filters for the grading interface.
 
 get_marking_workflow_states_for_current_user ()
 Get the list of marking_workflow states the current user has permission to transition a grade to.
 
 get_participant ($userid)
 Load a user if they are enrolled in the current course.
 
 get_plugin_by_type ($subtype, $type)
 Get a specific submission plugin by its type.
 
 get_renderer ()
 Lazy load the page renderer and expose the renderer to plugins.
 
 get_return_action ()
 Return an action that can be used to get back to the current page.
 
 get_return_params ()
 Return a list of parameters that can be used to get back to the current page.
 
 get_shared_group_members ($cm, $userid)
 Returns IDs of the users who share group membership with the specified user.
 
 get_submission_group ($userid)
 This is used for team assignments to get the group for the specified user.
 
 get_submission_group_members ($groupid, $onlyids, $excludesuspended=false)
 Get a list of the users in the same group as this user.
 
 get_submission_group_members_who_have_not_submitted ($groupid, $onlyids)
 Get a list of the users in the same group as this user that have not submitted the assignment.
 
 get_submission_plugin_by_type ($type)
 Get a submission plugin by type.
 
 get_submission_plugins ()
 Get list of submission plugins installed.
 
 get_timelimit_panel (stdClass $submission)
 Get the time limit panel object for this submission attempt.
 
 get_uniqueid_for_user ($userid)
 Call the static version of this function.
 
 get_user_flags ($userid, $create)
 This will retrieve a user flags object from the db optionally creating it if required.
 
 get_user_grade ($userid, $create, $attemptnumber=-1)
 This will retrieve a grade object from the db, optionally creating it if required.
 
 get_user_grades_for_gradebook ($userid)
 Get an upto date list of user grades and feedback for the gradebook.
 
 get_user_id_for_uniqueid ($uniqueid)
 Call the static version of this function.
 
 get_user_submission ($userid, $create, $attemptnumber=-1)
 Load the submission object for a particular user, optionally creating it if required.
 
 get_useridlist_key ($id=null)
 Generates the key that should be used for an entry in the useridlist cache.
 
 get_useridlist_key_id ()
 The id used to uniquily identify the cache for this instance of the assign object.
 
 get_valid_calendar_event_timestart_range (\calendar_event $event)
 This function calculates the minimum and maximum cutoff values for the timestart of the given event.
 
 grading_disabled ($userid, $checkworkflow=true, $gradinginfo=null)
 Determine if this users grade can be edited.
 
 has_instance ()
 Has this assignment been constructed from an instance?
 
 has_overrides ()
 Returns whether an assign has any overrides.
 
 has_submissions_or_grades ()
 Does an assignment have submission(s) or grade(s) already?
 
 is_active_user ($userid)
 Return true is user is active user in course else false.
 
 is_any_feedback_plugin_enabled ()
 Check if feedback plugins installed are enabled.
 
 is_any_submission_plugin_enabled ()
 Check if submission plugins installed are enabled.
 
 is_attempt_in_progress (?int $userid=null, int $groupid=0, int $attemptnumber=-1)
 Check if an assignment submission is already started and not yet submitted.
 
 is_blind_marking ()
 Is blind marking enabled and reveal identities not set yet?
 
 is_gradebook_feedback_enabled ()
 Returns true if gradebook feedback plugin is enabled.
 
 is_hidden_grader ()
 Is hidden grading enabled?
 
 is_override_calendar_event (\calendar_event $event)
 Check if the given calendar_event is either a user or group override event.
 
 is_time_limit_enabled (?int $userid=null)
 Check if time limit for assignment enabled and set up.
 
 is_userid_filtered ($userid)
 Is user id filtered by user filters and table preferences.
 
 list_participants ($currentgroup, $idsonly, $tablesort=false)
 Load a list of users enrolled in the current course with the specified permission and group.
 
 list_participants_with_filter_status_and_group ($currentgroup, $tablesort=false)
 Get the submission status/grading status for all submissions in this assignment.
 
 load_plugins ($subtype)
 Load the plugins from the sub folders under subtype.
 
 lock_submission ($userid)
 Prevent student updates to this submission.
 
 new_submission_empty ($data)
 Determine if a new submission is empty or not.
 
 notify_grade_modified ($grade, $mailedoverride=false)
 Mark in the database that this grade record should have an update notification sent by cron.
 
 override_exists ($userid)
 Returns user override.
 
 plugin_data_preprocessing (&$defaultvalues)
 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)
 
 register_return_link ($action, $params)
 Set the action and parameters that can be used to return to the current page.
 
 remove_submission ($userid)
 Remove any data from the current submission.
 
 render_area_files ($component, $area, $submissionid)
 Render the files in file area.
 
 render_editor_content ($filearea, $submissionid, $plugintype, $editor, $component, $shortentext=false)
 Render the content in editor that is often used by plugin.
 
 require_view_grades ()
 Throw an error if the permissions to view grades in this assignment are missing.
 
 require_view_group_submission ($groupid)
 Throw an error if the permissions to view this users' group submission are missing.
 
 require_view_submission ($userid)
 Throw an error if the permissions to view this users submission are missing.
 
 reset_userdata ($data)
 Actual implementation of the reset course functionality, delete all the assignment submissions for course $data->courseid.
 
 reveal_identities ()
 Reveal student identities to markers (and the gradebook).
 
 revert_to_draft ($userid)
 Revert to draft.
 
 save_grade ($userid, $data)
 Save grade update.
 
 save_submission (stdClass $data, & $notices)
 Save assignment submission for the current user.
 
 save_user_extension ($userid, $extensionduedate)
 Save the extension date for a single user.
 
 send_notification ($userfrom, $userto, $messagetype, $eventtype, $updatetime)
 Message someone about something.
 
 set_context (context $context)
 Set the context.
 
 set_course (stdClass $course)
 Set the course data.
 
 set_instance (stdClass $data)
 Set the submitted form data.
 
 set_module_viewed ()
 Update the module completion status (set it viewed) and trigger module viewed event.
 
 set_most_recent_team_submission ($submission)
 Set the most recent submission for the team.
 
 should_provide_intro_attachments (int $userid)
 Check if the intro attachments should be provided to the user.
 
 show_intro ()
 Based on the current assignment settings should we display the intro.
 
 show_only_active_users ()
 Check is only active users in course should be shown.
 
 submission_empty ($submission)
 Determine if the current submission is empty or not.
 
 submissions_open ($userid=0, $skipenrolled=false, $submission=false, $flags=false, $gradinginfo=false)
 Is this assignment open for submissions?
 
 submit_for_grading ($data, $notices)
 Submit a submission for grading.
 
 unlock_submission ($userid)
 Unlock the student submission.
 
 update_calendar ($coursemoduleid)
 Update the calendar entries for this assignment.
 
 update_effective_access ($userid)
 Updates the assign properties with override information for a user.
 
 update_grade ($grade, $reopenattempt=false)
 Update a grade in the grade table for the assignment and in the gradebook.
 
 update_gradebook ($reset, $coursemoduleid)
 Update the gradebook information for this assignment.
 
 update_instance ($formdata)
 Update this instance in the database.
 
 update_user_flags ($flags)
 Update user flags for this user in this assignment.
 
 view ($action='', $args=array())
 Display the assignment, used by view.php.
 
 view_batch_markingallocation ($mform)
 Shows a form that allows the allocated marker for selected submissions to be changed.
 
 view_student_summary ($user, $showlinks)
 Print 2 tables of information with no action links - the submission summary and the grading summary.
 
 view_submission_action_bar (stdClass $instance, stdClass $user)
 The action bar displayed in the submissions page.
 

Static Public Member Functions

static allocate_unique_ids ($assignid)
 Foreach participant in the course - assign them a random id.
 
static can_upgrade_assignment ($type, $version)
 This function is a static wrapper around can_upgrade.
 
static cron ()
 Finds all assignment notifications that have yet to be mailed out, and mails them.
 
static get_uniqueid_for_user_static ($assignid, $userid)
 Lookup this user id and return the unique id for this assignment.
 
static get_user_id_for_uniqueid_static ($assignid, $uniqueid)
 Lookup this unique id and return the user id for this assignment.
 
static send_assignment_notification ($userfrom, $userto, $messagetype, $eventtype, $updatetime, $coursemodule, $context, $course, $modulename, $assignmentname, $blindmarking, $uniqueidforuser)
 Message someone about something (static so it can be called from cron).
 

Public Attributes

float $grade
 grade value.
 

Protected Member Functions

 add_attempt ($userid)
 Add a new attempt for a user.
 
 add_grade_notices ()
 Checks for any grade notices, and adds notifications.
 
 add_plugin_grade_elements ($grade, MoodleQuickForm $mform, stdClass $data, $userid)
 Add elements in grading plugin form.
 
 add_plugin_settings (assign_plugin $plugin, MoodleQuickForm $mform, & $pluginsenabled)
 Add one plugins settings to edit plugin form.
 
 add_plugin_submission_elements ($submission, MoodleQuickForm $mform, stdClass $data, $userid)
 Add elements in submission plugin form.
 
 apply_grade_to_user ($formdata, $userid, $attemptnumber)
 Apply a grade from a grading form to a user (may be called multiple times for a group submission).
 
 check_submit_for_grading ($mform)
 Ask the user to confirm they want to submit their work for grading.
 
 convert_grade_for_gradebook (stdClass $grade)
 Convert the final raw grade(s) in the grading table for the gradebook.
 
 convert_submission_for_gradebook (stdClass $submission)
 Convert submission details for the gradebook.
 
 count_attachments ()
 Count the number of intro attachments.
 
 delete_grades ()
 Delete all grades from the gradebook for this assignment.
 
 download_submissions ($userids=null)
 Download a zip file of all assignment submissions.
 
 fix_null_grades ()
 View fix rescaled null grades.
 
 get_all_grades ($userid)
 Get the grades for all previous attempts.
 
 get_error_messages ()
 Get error messages.
 
 get_grade ($gradeid)
 This will retrieve a grade object from the db.
 
 get_graders ($userid)
 Returns a list of teachers that should be grading given submission.
 
 get_grading_instance ($userid, $grade, $gradingdisabled)
 Get an instance of a grading form if advanced grading is enabled.
 
 get_grading_userid_list ($cached=false, $useridlistid='')
 Utility function to get the userid for every row in the grading table so the order can be frozen while we iterate it.
 
 get_module_name ()
 Get the name of the current module.
 
 get_module_name_plural ()
 Get the plural name of the current module.
 
 get_notifiable_users ($userid)
 Returns a list of users that should receive notification about given submission.
 
 get_submission ($submissionid)
 Load the submission object from it's id.
 
 get_submissionstatement ($adminconfig, $instance, $context)
 Get the correct submission statement depending on single submisison, team submission or team submission where all team memebers must submit.
 
 get_submitted_sql ($group=0)
 Returns array with sql code and parameters returning all ids of users who have submitted an assignment.
 
 gradebook_item_update ($submission=null, $grade=null)
 Update grades in the gradebook.
 
 has_visible_attachments ()
 Are there any intro attachments to display?
 
 is_graded ($userid)
 See if this assignment has a grade yet.
 
 notify_graders (stdClass $submission)
 Send notifications to graders upon student submissions.
 
 notify_student_submission_copied (stdClass $submission)
 Notify student upon successful submission copy.
 
 notify_student_submission_receipt (stdClass $submission)
 Notify student upon successful submission.
 
 plagiarism_print_disclosure ()
 Capture the output of the plagiarism plugins disclosures and return it as a string.
 
 process_add_attempt ($userid)
 Check for a sess key and then call add_attempt.
 
 process_add_attempt_group ($useridlist)
 Add a new attempt for each user in the list - but reopen each group assignment at most 1 time.
 
 process_copy_previous_attempt (&$notices)
 Require a valid sess key and then call copy_previous_attempt.
 
 process_grading_batch_operation (& $mform)
 Ask the user to confirm they want to perform this batch operation.
 
 process_lock_submission ($userid=0)
 Prevent student updates to this submission.
 
 process_outcomes ($userid, $formdata, $sourceuserid=null)
 Save outcomes submitted from grading form.
 
 process_remove_submission ($userid=0)
 Remove the current submission.
 
 process_reveal_identities ()
 Reveal student identities to markers (and the gradebook).
 
 process_revert_to_draft ($userid=0)
 Revert to draft.
 
 process_save_extension (& $mform)
 Save extension date.
 
 process_save_grade (&$mform)
 Save grade.
 
 process_save_grading_options ()
 Save grading options.
 
 process_save_quick_grades ()
 Save quick grades.
 
 process_save_submission (&$mform, &$notices)
 Save assignment submission.
 
 process_set_batch_marking_allocation ()
 Set the marking allocation for multiple users.
 
 process_set_batch_marking_workflow_state ()
 Set the workflow state for multiple users.
 
 process_submit_for_grading ($mform, $notices)
 Assignment submission is processed before grading.
 
 process_submit_other_for_grading ($mform, $notices)
 A students submission is submitted for grading by a teacher.
 
 process_unlock_submission ($userid=0)
 Unlock the student submission.
 
 reopen_submission_if_required ($userid, $submission, $addattempt)
 If the requirements are met - reopen the submission for another attempt.
 
 save_editor_draft_files ($formdata)
 Save the attachments in the editor description.
 
 save_intro_draft_files ($formdata)
 Save the attachments in the intro description.
 
 set_error_message (string $message)
 Set error message.
 
 show_submit_button ($submission=null, $teamsubmission=null, $userid=null)
 Returns true if the submit subsission button should be shown to the user.
 
 update_activity_completion_records ($teamsubmission, $requireallteammemberssubmit, $submission, $userid, $complete, $completion)
 Updates and creates the completion records in mdl_course_modules_completion.
 
 update_plugin_instance (assign_plugin $plugin, stdClass $formdata)
 Update the settings for a single plugin.
 
 update_submission (stdClass $submission, $userid, $updatetime, $teamsubmission)
 Update grades in the gradebook based on submission time.
 
 update_team_submission (stdClass $submission, $userid, $updatetime)
 Update team submission.
 
 view_batch_set_workflow_state ($mform)
 Shows a form that allows the workflow state for selected submissions to be changed.
 
 view_edit_submission_page ($mform, $notices)
 View edit submissions page.
 
 view_fix_rescaled_null_grades ()
 View fix rescaled null grades.
 
 view_footer ()
 Display the page footer.
 
 view_grader ()
 View entire grader app.
 
 view_grading_page ()
 View entire grading page.
 
 view_grading_table ()
 View the grading table of all submissions for this assignment.
 
 view_grant_extension ($mform)
 View the grant extension date page.
 
 view_notices ($title, $notices)
 Message for students when assignment submissions have been closed.
 
 view_plugin_content ($pluginsubtype)
 Display the submission that is used by a plugin.
 
 view_plugin_grading_batch_operation ($mform)
 Allows the plugin to show a batch grading operation page.
 
 view_plugin_page ()
 View a page rendered by a plugin.
 
 view_quickgrading_result ($message)
 Display a continue page after quickgrading.
 
 view_remove_submission_confirm ()
 Show a confirmation page to make sure they want to remove submission data.
 
 view_return_links ()
 View a link to go back to the previous page.
 
 view_reveal_identities_confirm ()
 Show a confirmation page to make sure they want to release student identities.
 
 view_savegrading_result ($message)
 Display a continue page after grading.
 
 view_single_grade_page ($mform)
 Print the grading page for a single user submission.
 
 view_single_grading_panel ($args)
 Print the grading page for a single user submission.
 
 view_submission_page ()
 View submissions page (contains details of current submission).
 

Static Protected Member Functions

static format_notification_message_html ($messagetype, $info, $course, $context, $modulename, $coursemodule, $assignmentname)
 Format a notification for HTML.
 
static format_notification_message_text ($messagetype, $info, $course, $context, $modulename, $assignmentname)
 Format a notification for plain text.
 

Detailed Description

Standard base class for mod_assign (assignment types).

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

assign::__construct ( $coursemodulecontext,
$coursemodule,
$course )

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.

Parameters
mixed$coursemodulecontextcontext|null the course module context (or the course context if the coursemodule has not been created yet).
mixed$coursemodulethe current course module if it was already loaded, otherwise this class will load one from the context as required.
mixed$coursethe current course if it was already loaded, otherwise this class will load one from the context as required.

Member Function Documentation

◆ add_all_plugin_settings()

assign::add_all_plugin_settings ( MoodleQuickForm $mform)

Add settings to edit plugin form.

Parameters
MoodleQuickForm$mformThe form to add the configuration settings to. This form is modified directly (not returned).
Return values
void

◆ add_attempt()

assign::add_attempt ( $userid)
protected

Add a new attempt for a user.

Parameters
int$useridint The user to add the attempt for
Return values
bool- true if successful.

◆ add_grade_form_elements()

assign::add_grade_form_elements ( MoodleQuickForm $mform,
stdClass $data,
$params )

Add elements to grade form.

Parameters
MoodleQuickForm$mform
stdClass$data
array$params
Return values
void

◆ add_grade_notices()

assign::add_grade_notices ( )
protected

Checks for any grade notices, and adds notifications.

Will display on assignment main page and grading table.

Return values
voidThe notifications API will render the notifications at the appropriate part of the page.

◆ add_instance()

assign::add_instance ( stdClass $formdata,
$callplugins )

Add this instance to the database.

Parameters
stdClass$formdataThe data submitted from the form
bool$callpluginsThis is used to skip the plugin code when upgrading an old assignment to a new one (the plugins get called manually)
Return values
mixedfalse if an error occurs or the int id of the new instance

◆ add_plugin_grade_elements()

assign::add_plugin_grade_elements ( $grade,
MoodleQuickForm $mform,
stdClass $data,
$userid )
protected

Add elements in grading plugin form.

Parameters
mixed$gradestdClass|null
MoodleQuickForm$mform
stdClass$data
int$userid- The userid we are grading
Return values
void

◆ add_plugin_settings()

assign::add_plugin_settings ( assign_plugin $plugin,
MoodleQuickForm $mform,
& $pluginsenabled )
protected

Add one plugins settings to edit plugin form.

Parameters
assign_plugin$pluginThe plugin to add the settings from
MoodleQuickForm$mformThe form to add the configuration settings to. This form is modified directly (not returned).
array$pluginsenabledA list of form elements to be added to a group. The new element is added to this array by this function.
Return values
void

◆ add_plugin_submission_elements()

assign::add_plugin_submission_elements ( $submission,
MoodleQuickForm $mform,
stdClass $data,
$userid )
protected

Add elements in submission plugin form.

Parameters
mixed$submissionstdClass|null
MoodleQuickForm$mform
stdClass$data
int$useridThe current userid (same as $USER->id)
Return values
void

◆ add_submission_form_elements()

assign::add_submission_form_elements ( MoodleQuickForm $mform,
stdClass $data )

Add elements to submission form.

Parameters
MoodleQuickForm$mform
stdClass$data
Return values
void

◆ add_to_log()

assign::add_to_log ( $action = '',
$info = '',
$url = '',
$return = false )

Util function to add a message to the log.

Deprecated
since 2.7 - Use new events system instead. (see http://docs.moodle.org/dev/Migrating_logging_calls_in_plugins).
Parameters
string$actionThe current action
string$infoA detailed description of the change. But no more than 255 characters.
string$urlThe url to the assign module instance.
bool$returnIf true, returns the arguments, else adds to log. The purpose of this is to retrieve the arguments to use them with the new event system (Event 2).
Return values
void|array

◆ allocate_unique_ids()

static assign::allocate_unique_ids ( $assignid)
static

Foreach participant in the course - assign them a random id.

Parameters
int$assignidThe assignid to lookup

◆ apply_grade_to_user()

assign::apply_grade_to_user ( $formdata,
$userid,
$attemptnumber )
protected

Apply a grade from a grading form to a user (may be called multiple times for a group submission).

Parameters
stdClass$formdata- the data from the form
int$userid- the user to apply the grade to
int$attemptnumber- The attempt number to apply the grade to.
Return values
void

◆ can_edit_group_submission()

assign::can_edit_group_submission ( $groupid)

Perform an access check to see if the current $USER can edit this group submission.

Parameters
int$groupid
Return values
bool

◆ can_edit_submission()

assign::can_edit_submission ( $userid,
$graderid = 0 )

Capability check to make sure this grader can edit this submission.

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

◆ can_grade()

assign::can_grade ( $user = null)

Does this user have grade permission for this assignment?

Parameters
int | stdClass$userThe object or id of the user who will do the editing (default to current user).
Return values
bool

◆ can_upgrade()

assign::can_upgrade ( $type,
$version )

This function returns true if it can upgrade an assignment from the 2.2 module.

Parameters
string$typeThe plugin type
int$versionThe plugin version
Return values
bool

◆ can_upgrade_assignment()

static assign::can_upgrade_assignment ( $type,
$version )
static

This function is a static wrapper around can_upgrade.

Parameters
string$typeThe plugin type
int$versionThe plugin version
Return values
bool

◆ can_view_grades()

assign::can_view_grades ( $groupid = null)

Does this user have view grade or grade permission for this assignment?

Parameters
mixed$groupidint|null when is set to a value, use this group instead calculating it
Return values
bool

◆ can_view_group_submission()

assign::can_view_group_submission ( $groupid)

Perform an access check to see if the current $USER can view this group submission.

Parameters
int$groupid
Return values
bool

◆ can_view_submission()

assign::can_view_submission ( $userid)

Perform an access check to see if the current $USER can view this users submission.

Parameters
int$userid
Return values
bool

◆ check_submit_for_grading()

assign::check_submit_for_grading ( $mform)
protected

Ask the user to confirm they want to submit their work for grading.

Parameters
moodleform$mform- null unless form validation has failed
Return values
string

◆ convert_grade_for_gradebook()

assign::convert_grade_for_gradebook ( stdClass $grade)
protected

Convert the final raw grade(s) in the grading table for the gradebook.

Parameters
stdClass$grade
Return values
array

◆ convert_submission_for_gradebook()

assign::convert_submission_for_gradebook ( stdClass $submission)
protected

Convert submission details for the gradebook.

Parameters
stdClass$submission
Return values
array

◆ copy_area_files_for_upgrade()

assign::copy_area_files_for_upgrade ( $oldcontextid,
$oldcomponent,
$oldfilearea,
$olditemid,
$newcontextid,
$newcomponent,
$newfilearea,
$newitemid )

Copy all the files from the old assignment files area to the new one.

This is used by the plugin upgrade code.

Parameters
int$oldcontextidThe old assignment context id
int$oldcomponentThe old assignment component ('assignment')
int$oldfileareaThe old assignment filearea ('submissions')
int$olditemidThe old submissionid (can be null e.g. intro)
int$newcontextidThe new assignment context id
int$newcomponentThe new assignment component ('assignment')
int$newfileareaThe new assignment filearea ('submissions')
int$newitemidThe new submissionid (can be null e.g. intro)
Return values
intThe number of files copied

◆ copy_previous_attempt()

assign::copy_previous_attempt ( & $notices)

Copy the current assignment submission from the last submitted attempt.

Parameters
array$noticesAny error messages that should be shown to the user at the top of the edit submission form.
Return values
bool

◆ count_attachments()

assign::count_attachments ( )
protected

Count the number of intro attachments.

Return values
int

◆ count_grades()

assign::count_grades ( )

Load a count of grades.

Return values
intnumber of grades

◆ count_participants()

assign::count_participants ( $currentgroup)

Load a count of active users enrolled in the current course with the specified permission and group.

0 for no group.

Parameters
int$currentgroup
Return values
intnumber of matching users

◆ count_submissions()

assign::count_submissions ( $includenew = false)

Load a count of submissions.

Parameters
bool$includenewWhen true, also counts the submissions with status 'new'.
Return values
intnumber of submissions

◆ count_submissions_need_grading()

assign::count_submissions_need_grading ( $currentgroup = null)

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.

Parameters
mixed$currentgroupint|null the group for counting (if null the function will determine it)
Return values
intnumber of matching submissions

◆ count_submissions_with_status()

assign::count_submissions_with_status ( $status,
$currentgroup = null )

Load a count of submissions with a specified status.

Parameters
string$statusThe submission status - should match one of the constants
mixed$currentgroupint|null the group for counting (if null the function will determine it)
Return values
intnumber of matching submissions

◆ count_teams()

assign::count_teams ( $activitygroup = 0)

Load a count of valid teams for this assignment.

Parameters
int$activitygroupActivity active group
Return values
intnumber of valid teams

◆ cron()

static assign::cron ( )
static

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 values
bool

◆ delete_grades()

assign::delete_grades ( )
protected

Delete all grades from the gradebook for this assignment.

Return values
bool

◆ delete_instance()

assign::delete_instance ( )

Delete this instance from the database.

Return values
boolfalse if an error occurs

◆ delete_override()

assign::delete_override ( $overrideid)

Deletes a assign override from the database and clears any corresponding calendar events.

Parameters
int$overrideidThe id of the override being deleted
Return values
booltrue on success

◆ display_grade()

assign::display_grade ( $grade,
$editing,
$userid = 0,
$modified = 0 )

Return a grade in user-friendly form, whether it's a scale or not.

Parameters
mixed$gradeint|null
boolean$editingAre we allowing changes to this grade?
int$useridThe user id the grade belongs to
int$modifiedTimestamp from when the grade was last modified
Return values
stringUser-friendly representation of grade

◆ download_rewrite_pluginfile_urls()

assign::download_rewrite_pluginfile_urls ( $text,
$user,
$plugin )

Rewrite plugin file urls so they resolve correctly in an exported zip.

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

◆ download_submissions()

assign::download_submissions ( $userids = null)
protected

Download a zip file of all assignment submissions.

Parameters
array | null$useridsArray of user ids to download assignment submissions in a zip file
Return values
string- If an error occurs, this will contain the error page.

◆ fix_null_grades()

assign::fix_null_grades ( )
protected

View fix rescaled null grades.

Return values
boolTrue if null all grades are now fixed.

◆ format_grade_for_log()

assign::format_grade_for_log ( stdClass $grade)

Take a grade object and print a short summary for the log file.

The size limit for the log file is 255 characters, so be careful not to include too much information.

Deprecated
since 2.7
Parameters
stdClass$grade
Return values
string

◆ format_notification_message_html()

static assign::format_notification_message_html ( $messagetype,
$info,
$course,
$context,
$modulename,
$coursemodule,
$assignmentname )
staticprotected

Format a notification for HTML.

Parameters
string$messagetype
stdClass$info
stdClass$course
stdClass$context
string$modulename
stdClass$coursemodule
string$assignmentname

◆ format_notification_message_text()

static assign::format_notification_message_text ( $messagetype,
$info,
$course,
$context,
$modulename,
$assignmentname )
staticprotected

Format a notification for plain text.

Parameters
string$messagetype
stdClass$info
stdClass$course
stdClass$context
string$modulename
string$assignmentname

◆ format_submission_for_log()

assign::format_submission_for_log ( stdClass $submission)

Take a submission object and print a short summary for the log file.

The size limit for the log file is 255 characters, so be careful not to include too much information.

Deprecated
since 2.7
Parameters
stdClass$submission
Return values
string

◆ fullname()

assign::fullname ( $user)

Get the name for a user - hiding their real name if blind marking is on.

Parameters
stdClass$userThe user record as required by fullname()
Return values
stringThe name.

◆ get_admin_config()

assign::get_admin_config ( )

Load and cache the admin config for this module.

Return values
stdClassthe plugin config

◆ get_all_grades()

assign::get_all_grades ( $userid)
protected

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).

Parameters
int$useridIf not set, $USER->id will be used.
Return values
array\$gradesAll grade records for this user.

◆ get_all_groups()

assign::get_all_groups ( $userid)

Gets all groups the user is a member of.

Parameters
int$useridTeh id of the user who's groups we are checking
Return values
arrayThe group objects

◆ get_all_submissions()

assign::get_all_submissions ( $userid)

Get the submissions for all previous attempts.

Parameters
int$useridIf not set, $USER->id will be used.
Return values
array\$submissionsAll submission records for this user (or group).

◆ get_assign_attempt_history_renderable()

assign::get_assign_attempt_history_renderable ( $user)

Creates an assign_attempt_history renderable.

Parameters
stdClass$userthe user to get the report for
Return values
assign_attempt_historyrenderable object

◆ get_assign_feedback_status_renderable()

assign::get_assign_feedback_status_renderable ( $user)

Creates an assign_feedback_status renderable.

Parameters
stdClass$userthe user to get the report for
Return values
assign_feedback_statusrenderable object

◆ get_assign_grading_summary_renderable()

assign::get_assign_grading_summary_renderable ( $activitygroup = null)

Creates an assign_grading_summary renderable.

Parameters
mixed$activitygroupint|null the group for calculating the grading summary (if null the function will determine it)
Return values
assign_grading_summaryrenderable object

◆ get_assign_perpage()

assign::get_assign_perpage ( )

Get the marking table page size.

Return values
integer

◆ get_assign_submission_status_renderable()

assign::get_assign_submission_status_renderable ( $user,
$showlinks )

Creates an assign_submission_status renderable.

Parameters
stdClass$userthe user to get the report for
bool$showlinksreturn plain text or links to the profile
Return values
assign_submission_statusrenderable object

◆ get_context()

assign::get_context ( )

Get context module.

Return values
context

◆ get_course()

assign::get_course ( )

Get the current course.

Return values
mixedstdClass|null The course

◆ get_course_context()

assign::get_course_context ( )

Get the context of the current course.

Return values
mixedcontext|null The course context

◆ get_course_module()

assign::get_course_module ( )

Get the current course module.

Return values
cm_info|nullThe course module or null if not known

◆ get_default_instance()

assign::get_default_instance ( )

Get the settings for the current instance of this assignment.

Return values
stdClassThe settings
Exceptions
dml_exception

◆ get_error_messages()

assign::get_error_messages ( )
protected

Get error messages.

Return values
arrayThe array of error messages

◆ get_feedback_plugin_by_type()

assign::get_feedback_plugin_by_type ( $type)

Get a feedback plugin by type.

Parameters
string$type- The type of plugin e.g comments
Return values
mixedassign_feedback_plugin|null

◆ get_feedback_plugins()

assign::get_feedback_plugins ( )

Get list of feedback plugins installed.

Return values
array

◆ get_filters()

assign::get_filters ( )

Return array of valid search filters for the grading interface.

Return values
array

◆ get_grade()

assign::get_grade ( $gradeid)
protected

This will retrieve a grade object from the db.

Parameters
int$gradeidThe id of the grade
Return values
stdClassThe grade record

◆ get_grade_item()

assign::get_grade_item ( )

Get the primary grade item for this assign instance.

Return values
grade_itemThe grade_item record

◆ get_graders()

assign::get_graders ( $userid)
protected

Returns a list of teachers that should be grading given submission.

Parameters
int$useridThe submission to grade
Return values
array

◆ get_grading_instance()

assign::get_grading_instance ( $userid,
$grade,
$gradingdisabled )
protected

Get an instance of a grading form if advanced grading is enabled.

This is specific to the assignment, marker and student.

Parameters
int$userid- The student userid
stdClass | false$grade- The grade record
bool$gradingdisabled
Return values
mixedgradingform_instance|null $gradinginstance

◆ get_grading_status()

assign::get_grading_status ( $userid)

Returns the grading status.

Parameters
int$useridthe user id
Return values
stringreturns the grading status

◆ get_grading_userid_list()

assign::get_grading_userid_list ( $cached = false,
$useridlistid = '' )
protected

Utility function to get the userid for every row in the grading table so the order can be frozen while we iterate it.

Parameters
boolean$cachedIf true, the cached list from the session could be returned.
string$useridlistidString value used for caching the participant list.
Return values
arrayAn array of userids

◆ get_group_submission()

assign::get_group_submission ( $userid,
$groupid,
$create,
$attemptnumber = -1 )

Load the group submission object for a particular user, optionally creating it if required.

Parameters
int$useridThe id of the user whose submission we want
int$groupidThe id of the group for this user - may be 0 in which case it is determined from the userid.
bool$createIf set to true a new submission object will be created in the database with the status set to "new".
int$attemptnumber- -1 means the latest attempt
Return values
stdClass|falseThe submission

◆ get_instance()

assign::get_instance ( int $userid = null)

Get the settings for the current instance of this assignment.

Parameters
int | null$useridthe id of the user to load the assign instance for.
Return values
stdClassThe settings

◆ get_marking_allocation_filters()

assign::get_marking_allocation_filters ( $export = false)

Return array of valid grading allocation filters for the grading interface.

Parameters
boolean$exportExport the list of filters for a template.
Return values
array

◆ get_marking_workflow_filters()

assign::get_marking_workflow_filters ( $export = false)

Return array of valid grading workflow filters for the grading interface.

Parameters
boolean$exportExport the list of filters for a template.
Return values
array

◆ get_marking_workflow_states_for_current_user()

assign::get_marking_workflow_states_for_current_user ( )

Get the list of marking_workflow states the current user has permission to transition a grade to.

Return values
arrayof state => description

◆ get_module_name()

assign::get_module_name ( )
protected

Get the name of the current module.

Return values
stringthe module name (Assignment)

◆ get_module_name_plural()

assign::get_module_name_plural ( )
protected

Get the plural name of the current module.

Return values
stringthe module name plural (Assignments)

◆ get_notifiable_users()

assign::get_notifiable_users ( $userid)
protected

Returns a list of users that should receive notification about given submission.

Parameters
int$useridThe submission to grade
Return values
array

◆ get_participant()

assign::get_participant ( $userid)

Load a user if they are enrolled in the current course.

Populated with submission status for this assignment.

Parameters
int$userid
Return values
null|stdClassuser record

◆ get_plugin_by_type()

assign::get_plugin_by_type ( $subtype,
$type )

Get a specific submission plugin by its type.

Parameters
string$subtypeassignsubmission | assignfeedback
string$type
Return values
mixedassign_plugin|null

◆ get_renderer()

assign::get_renderer ( )

Lazy load the page renderer and expose the renderer to plugins.

Return values
assign_renderer

◆ get_return_action()

assign::get_return_action ( )

Return an action that can be used to get back to the current page.

Return values
stringaction

◆ get_return_params()

assign::get_return_params ( )

Return a list of parameters that can be used to get back to the current page.

Return values
arrayparams

◆ get_shared_group_members()

assign::get_shared_group_members ( $cm,
$userid )

Returns IDs of the users who share group membership with the specified user.

Parameters
stdClass | cm_info$cmCourse-module
int$useridUser ID
Return values
arrayAn array of ID of users.

◆ get_submission()

assign::get_submission ( $submissionid)
protected

Load the submission object from it's id.

Parameters
int$submissionidThe id of the submission we want
Return values
stdClassThe submission

◆ get_submission_group()

assign::get_submission_group ( $userid)

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

Parameters
int$useridThe id of the user whose submission we want
Return values
mixedThe group or false

◆ get_submission_group_members()

assign::get_submission_group_members ( $groupid,
$onlyids,
$excludesuspended = false )

Get a list of the users in the same group as this user.

Parameters
int$groupidThe id of the group whose members we want or 0 for the default group
bool$onlyidsWhether to retrieve only the user id's
bool$excludesuspendedWhether to exclude suspended users
Return values
arrayThe users (possibly id's only)

◆ get_submission_group_members_who_have_not_submitted()

assign::get_submission_group_members_who_have_not_submitted ( $groupid,
$onlyids )

Get a list of the users in the same group as this user that have not submitted the assignment.

Parameters
int$groupidThe id of the group whose members we want or 0 for the default group
bool$onlyidsWhether to retrieve only the user id's
Return values
arrayThe users (possibly id's only)

◆ get_submission_plugin_by_type()

assign::get_submission_plugin_by_type ( $type)

Get a submission plugin by type.

Parameters
string$type- The type of plugin e.g comments
Return values
mixedassign_submission_plugin|null

◆ get_submission_plugins()

assign::get_submission_plugins ( )

Get list of submission plugins installed.

Return values
array

◆ get_submissionstatement()

assign::get_submissionstatement ( $adminconfig,
$instance,
$context )
protected

Get the correct submission statement depending on single submisison, team submission or team submission where all team memebers must submit.

Parameters
stdClass$adminconfig
stdClass$instance
context$context
Return values
string

◆ get_submitted_sql()

assign::get_submitted_sql ( $group = 0)
protected

Returns array with sql code and parameters returning all ids of users who have submitted an assignment.

Parameters
int$groupThe group that the query is for.
Return values
arraylist($sql, $params)

◆ get_timelimit_panel()

assign::get_timelimit_panel ( stdClass $submission)

Get the time limit panel object for this submission attempt.

Parameters
stdClass$submissionassign submission.
Return values
stringthe panel output.

◆ get_uniqueid_for_user()

assign::get_uniqueid_for_user ( $userid)

Call the static version of this function.

Parameters
int$useridThe userid to lookup
Return values
intThe unique id

◆ get_uniqueid_for_user_static()

static assign::get_uniqueid_for_user_static ( $assignid,
$userid )
static

Lookup this user id and return the unique id for this assignment.

Parameters
int$assignidThe assignment id
int$useridThe userid to lookup
Return values
intThe unique id

◆ get_user_flags()

assign::get_user_flags ( $userid,
$create )

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.

Parameters
int$useridThe user we are getting the flags for.
bool$createIf true the flags record will be created if it does not exist
Return values
stdClassThe flags record

◆ get_user_grade()

assign::get_user_grade ( $userid,
$create,
$attemptnumber = -1 )

This will retrieve a grade object from the db, optionally creating it if required.

Parameters
int$useridThe user we are grading
bool$createIf true the grade will be created if it does not exist
int$attemptnumberThe attempt number to retrieve the grade for. -1 means the latest submission.
Return values
stdClassThe grade record

◆ get_user_grades_for_gradebook()

assign::get_user_grades_for_gradebook ( $userid)

Get an upto date list of user grades and feedback for the gradebook.

Parameters
int$useridint or 0 for all users
Return values
arrayof grade data formated for the gradebook api The data required by the gradebook api is userid, rawgrade, feedback, feedbackformat, usermodified, dategraded, datesubmitted

◆ get_user_id_for_uniqueid()

assign::get_user_id_for_uniqueid ( $uniqueid)

Call the static version of this function.

Parameters
int$uniqueidThe uniqueid to lookup
Return values
intThe user id or false if they don't exist

◆ get_user_id_for_uniqueid_static()

static assign::get_user_id_for_uniqueid_static ( $assignid,
$uniqueid )
static

Lookup this unique id and return the user id for this assignment.

Parameters
int$assignidThe id of the assignment this user mapping is in
int$uniqueidThe uniqueid to lookup
Return values
intThe user id or false if they don't exist

◆ get_user_submission()

assign::get_user_submission ( $userid,
$create,
$attemptnumber = -1 )

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.

Parameters
int$useridThe id of the user whose submission we want or 0 in which case USER->id is used
bool$createIf set to true a new submission object will be created in the database with the status set to "new".
int$attemptnumber- -1 means the latest attempt
Return values
stdClass|falseThe submission

◆ get_useridlist_key()

assign::get_useridlist_key ( $id = null)

Generates the key that should be used for an entry in the useridlist cache.

Parameters
string$idGenerate a key for this instance (optional)
Return values
stringThe key for the id, or new entry if no $id is passed.

◆ get_useridlist_key_id()

assign::get_useridlist_key_id ( )

The id used to uniquily identify the cache for this instance of the assign object.

Return values
string

◆ get_valid_calendar_event_timestart_range()

assign::get_valid_calendar_event_timestart_range ( \calendar_event $event)

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.

Parameters
calendar_event$eventThe calendar event to get the time range for
Return values
array

◆ gradebook_item_update()

assign::gradebook_item_update ( $submission = null,
$grade = null )
protected

Update grades in the gradebook.

Parameters
mixed$submissionstdClass|null
mixed$gradestdClass|null
Return values
bool

◆ grading_disabled()

assign::grading_disabled ( $userid,
$checkworkflow = true,
$gradinginfo = null )

Determine if this users grade can be edited.

Parameters
int$userid- The student userid
bool$checkworkflow- whether to include a check for the workflow state.
stdClass$gradinginfo- optional, allow gradinginfo to be passed for performance.
Return values
bool\$gradingdisabled

◆ has_instance()

assign::has_instance ( )

Has this assignment been constructed from an instance?

Return values
bool

◆ has_overrides()

assign::has_overrides ( )

Returns whether an assign has any overrides.

Return values
trueif any, false if not

◆ has_submissions_or_grades()

assign::has_submissions_or_grades ( )

Does an assignment have submission(s) or grade(s) already?

Return values
bool

◆ has_visible_attachments()

assign::has_visible_attachments ( )
protected

Are there any intro attachments to display?

Return values
boolean

◆ is_active_user()

assign::is_active_user ( $userid)

Return true is user is active user in course else false.

Parameters
int$userid
Return values
booltrue is user is active in course.

◆ is_any_feedback_plugin_enabled()

assign::is_any_feedback_plugin_enabled ( )

Check if feedback plugins installed are enabled.

Return values
bool

◆ is_any_submission_plugin_enabled()

assign::is_any_submission_plugin_enabled ( )

Check if submission plugins installed are enabled.

Return values
bool

◆ is_attempt_in_progress()

assign::is_attempt_in_progress ( ?int $userid = null,
int $groupid = 0,
int $attemptnumber = -1 )

Check if an assignment submission is already started and not yet submitted.

Parameters
int | null$useridUser ID. If null, use global user.
int$groupidGroup ID. If 0, use user id to determine group.
int$attemptnumberAttempt number. If -1, check latest submission.
Return values
bool

◆ is_blind_marking()

assign::is_blind_marking ( )

Is blind marking enabled and reveal identities not set yet?

Return values
bool

◆ is_gradebook_feedback_enabled()

assign::is_gradebook_feedback_enabled ( )

Returns true if gradebook feedback plugin is enabled.

Return values
booltrue if gradebook feedback plugin is enabled and visible else false.

◆ is_graded()

assign::is_graded ( $userid)
protected

See if this assignment has a grade yet.

Parameters
int$userid
Return values
bool

◆ is_hidden_grader()

assign::is_hidden_grader ( )

Is hidden grading enabled?

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

Return values
bool

◆ is_override_calendar_event()

assign::is_override_calendar_event ( \calendar_event $event)

Check if the given calendar_event is either a user or group override event.

Return values
bool

◆ is_time_limit_enabled()

assign::is_time_limit_enabled ( ?int $userid = null)

Check if time limit for assignment enabled and set up.

Parameters
int | null$useridUser ID. If null, use global user.
Return values
bool

◆ is_userid_filtered()

assign::is_userid_filtered ( $userid)

Is user id filtered by user filters and table preferences.

Parameters
int$useridUser id that needs to be checked.
Return values
bool

◆ list_participants()

assign::list_participants ( $currentgroup,
$idsonly,
$tablesort = false )

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.

Parameters
int$currentgroup
bool$idsonly
bool$tablesort
Return values
arrayList of user records

◆ list_participants_with_filter_status_and_group()

assign::list_participants_with_filter_status_and_group ( $currentgroup,
$tablesort = false )

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.

Parameters
int$currentgroup
boolean$tablesortApply current user table sorting preferences.
Return values
arrayList of user records with extra fields 'submitted', 'notsubmitted', 'requiregrading', 'grantedextension', 'groupid', 'groupname'

◆ load_plugins()

assign::load_plugins ( $subtype)

Load the plugins from the sub folders under subtype.

Parameters
string$subtype- either submission or feedback
Return values
array- The sorted list of plugins

◆ lock_submission()

assign::lock_submission ( $userid)

Prevent student updates to this submission.

Parameters
int$userid
Return values
bool

◆ new_submission_empty()

assign::new_submission_empty ( $data)

Determine if a new submission is empty or not.

Parameters
stdClass$dataSubmission data
Return values
bool

◆ notify_grade_modified()

assign::notify_grade_modified ( $grade,
$mailedoverride = false )

Mark in the database that this grade record should have an update notification sent by cron.

Parameters
stdClass$gradea grade record keyed on id
bool$mailedoverridewhen true, flag notification to be sent again.
Return values
booltrue for success

◆ notify_graders()

assign::notify_graders ( stdClass $submission)
protected

Send notifications to graders upon student submissions.

Parameters
stdClass$submission
Return values
void

◆ notify_student_submission_copied()

assign::notify_student_submission_copied ( stdClass $submission)
protected

Notify student upon successful submission copy.

Parameters
stdClass$submission
Return values
void

◆ notify_student_submission_receipt()

assign::notify_student_submission_receipt ( stdClass $submission)
protected

Notify student upon successful submission.

Parameters
stdClass$submission
Return values
void

◆ override_exists()

assign::override_exists ( $userid)

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.

Parameters
int$useridThe userid.
Return values
stdClassThe override

◆ plagiarism_print_disclosure()

assign::plagiarism_print_disclosure ( )
protected

Capture the output of the plagiarism plugins disclosures and return it as a string.

Return values
string

◆ plugin_data_preprocessing()

assign::plugin_data_preprocessing ( & $defaultvalues)

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)

Parameters
array$defaultvalues

◆ process_add_attempt()

assign::process_add_attempt ( $userid)
protected

Check for a sess key and then call add_attempt.

Parameters
int$useridint The user to add the attempt for
Return values
bool- true if successful.

◆ process_add_attempt_group()

assign::process_add_attempt_group ( $useridlist)
protected

Add a new attempt for each user in the list - but reopen each group assignment at most 1 time.

Parameters
array$useridlistArray of userids to reopen.
Return values
bool

◆ process_copy_previous_attempt()

assign::process_copy_previous_attempt ( & $notices)
protected

Require a valid sess key and then call copy_previous_attempt.

Parameters
array$noticesAny error messages that should be shown to the user at the top of the edit submission form.
Return values
bool

◆ process_grading_batch_operation()

assign::process_grading_batch_operation ( & $mform)
protected

Ask the user to confirm they want to perform this batch operation.

Parameters
moodleform$mformSet to a grading batch operations form
Return values
string- the page to view after processing these actions

◆ process_lock_submission()

assign::process_lock_submission ( $userid = 0)
protected

Prevent student updates to this submission.

Uses url parameter userid.

Parameters
int$userid
Return values
void

◆ process_outcomes()

assign::process_outcomes ( $userid,
$formdata,
$sourceuserid = null )
protected

Save outcomes submitted from grading form.

Parameters
int$userid
stdClass$formdata
int$sourceuseridThe user ID under which the outcome data is accessible. This is relevant for an outcome set to a user but applied to an entire group.

◆ process_remove_submission()

assign::process_remove_submission ( $userid = 0)
protected

Remove the current submission.

Parameters
int$userid
Return values
boolean

◆ process_reveal_identities()

assign::process_reveal_identities ( )
protected

Reveal student identities to markers (and the gradebook).

Return values
void

◆ process_revert_to_draft()

assign::process_revert_to_draft ( $userid = 0)
protected

Revert to draft.

Uses url parameter userid if userid not supplied as a parameter.

Parameters
int$userid
Return values
boolean

◆ process_save_extension()

assign::process_save_extension ( & $mform)
protected

Save extension date.

Parameters
moodleform$mformThe submitted form
Return values
boolean

◆ process_save_grade()

assign::process_save_grade ( & $mform)
protected

Save grade.

Parameters
moodleform$mform
Return values
bool- was the grade saved

◆ process_save_grading_options()

assign::process_save_grading_options ( )
protected

Save grading options.

Return values
void

◆ process_save_quick_grades()

assign::process_save_quick_grades ( )
protected

Save quick grades.

Return values
stringThe result of the save operation

◆ process_save_submission()

assign::process_save_submission ( & $mform,
& $notices )
protected

Save assignment submission.

Parameters
moodleform$mform
array$noticesAny error messages that should be shown to the user at the top of the edit submission form.
Return values
bool

◆ process_set_batch_marking_allocation()

assign::process_set_batch_marking_allocation ( )
protected

Set the marking allocation for multiple users.

Return values
void

◆ process_set_batch_marking_workflow_state()

assign::process_set_batch_marking_workflow_state ( )
protected

Set the workflow state for multiple users.

Return values
void

◆ process_submit_for_grading()

assign::process_submit_for_grading ( $mform,
$notices )
protected

Assignment submission is processed before grading.

Parameters
moodleform | null$mformIf validation failed when submitting this form - this is the moodleform. It can be null.
Return values
boolReturn false if the validation fails. This affects which page is displayed next.

◆ process_submit_other_for_grading()

assign::process_submit_other_for_grading ( $mform,
$notices )
protected

A students submission is submitted for grading by a teacher.

Return values
bool

◆ process_unlock_submission()

assign::process_unlock_submission ( $userid = 0)
protected

Unlock the student submission.

Uses url parameter userid.

Parameters
int$userid
Return values
bool

◆ register_return_link()

assign::register_return_link ( $action,
$params )

Set the action and parameters that can be used to return to the current page.

Parameters
string$actionThe action for the current page
array$paramsAn array of name value pairs which form the parameters to return to the current page.
Return values
void

◆ remove_submission()

assign::remove_submission ( $userid)

Remove any data from the current submission.

Parameters
int$userid
Return values
boolean
Exceptions
coding_exception

◆ render_area_files()

assign::render_area_files ( $component,
$area,
$submissionid )

Render the files in file area.

Parameters
string$component
string$area
int$submissionid
Return values
string

◆ render_editor_content()

assign::render_editor_content ( $filearea,
$submissionid,
$plugintype,
$editor,
$component,
$shortentext = false )

Render the content in editor that is often used by plugin.

Parameters
string$filearea
int$submissionid
string$plugintype
string$editor
string$component
bool$shortentextWhether to shorten the text content.
Return values
string

◆ reopen_submission_if_required()

assign::reopen_submission_if_required ( $userid,
$submission,
$addattempt )
protected

If the requirements are met - reopen the submission for another attempt.

Only call this function when grading the latest attempt.

Parameters
int$useridThe userid.
stdClass$submissionThe submission (may be a group submission).
bool$addattempt- True if the "allow another attempt" checkbox was checked.
Return values
bool- true if another attempt was added.

◆ require_view_grades()

assign::require_view_grades ( )

Throw an error if the permissions to view grades in this assignment are missing.

Exceptions
required_capability_exception
Return values
none

◆ require_view_group_submission()

assign::require_view_group_submission ( $groupid)

Throw an error if the permissions to view this users' group submission are missing.

Parameters
int$groupidGroup id.
Exceptions
required_capability_exception

◆ require_view_submission()

assign::require_view_submission ( $userid)

Throw an error if the permissions to view this users submission are missing.

Exceptions
required_capability_exception
Return values
none

◆ reset_userdata()

assign::reset_userdata ( $data)

Actual implementation of the reset course functionality, delete all the assignment submissions for course $data->courseid.

Parameters
stdClass$datathe data submitted from the reset course.
Return values
arraystatus array

◆ reveal_identities()

assign::reveal_identities ( )

Reveal student identities to markers (and the gradebook).

Return values
void

◆ revert_to_draft()

assign::revert_to_draft ( $userid)

Revert to draft.

Parameters
int$userid
Return values
boolean

◆ save_editor_draft_files()

assign::save_editor_draft_files ( $formdata)
protected

Save the attachments in the editor description.

Parameters
stdClass$formdata

◆ save_grade()

assign::save_grade ( $userid,
$data )

Save grade update.

Parameters
int$userid
stdClass$data
Return values
bool- was the grade saved

◆ save_intro_draft_files()

assign::save_intro_draft_files ( $formdata)
protected

Save the attachments in the intro description.

Parameters
stdClass$formdata

◆ save_submission()

assign::save_submission ( stdClass $data,
& $notices )

Save assignment submission for the current user.

Parameters
stdClass$data
array$noticesAny error messages that should be shown to the user.
Return values
bool

◆ save_user_extension()

assign::save_user_extension ( $userid,
$extensionduedate )

Save the extension date for a single user.

Parameters
int$useridThe user id
mixed$extensionduedateEither an integer date or null
Return values
boolean

◆ send_assignment_notification()

static assign::send_assignment_notification ( $userfrom,
$userto,
$messagetype,
$eventtype,
$updatetime,
$coursemodule,
$context,
$course,
$modulename,
$assignmentname,
$blindmarking,
$uniqueidforuser )
static

Message someone about something (static so it can be called from cron).

Parameters
stdClass$userfrom
stdClass$userto
string$messagetype
string$eventtype
int$updatetime
stdClass$coursemodule
stdClass$context
stdClass$course
string$modulename
string$assignmentname
bool$blindmarking
int$uniqueidforuser
Return values
void

◆ send_notification()

assign::send_notification ( $userfrom,
$userto,
$messagetype,
$eventtype,
$updatetime )

Message someone about something.

Parameters
stdClass$userfrom
stdClass$userto
string$messagetype
string$eventtype
int$updatetime
Return values
void

◆ set_context()

assign::set_context ( context $context)

Set the context.

Parameters
context$contextThe new context

◆ set_course()

assign::set_course ( stdClass $course)

Set the course data.

Parameters
stdClass$courseThe course data

◆ set_error_message()

assign::set_error_message ( string $message)
protected

Set error message.

Parameters
string$messageThe error message

◆ set_instance()

assign::set_instance ( stdClass $data)

Set the submitted form data.

Parameters
stdClass$dataThe form data (instance)

◆ set_module_viewed()

assign::set_module_viewed ( )

Update the module completion status (set it viewed) and trigger module viewed event.

Since
Moodle 3.2

◆ set_most_recent_team_submission()

assign::set_most_recent_team_submission ( $submission)

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.

Since
Moodle 3.4
Parameters
stdClass$submissionThe most recent submission of the group.

◆ should_provide_intro_attachments()

assign::should_provide_intro_attachments ( int $userid)

Check if the intro attachments should be provided to the user.

Parameters
int$useridUser id.
Return values
bool

◆ show_intro()

assign::show_intro ( )

Based on the current assignment settings should we display the intro.

Return values
boolshowintro

◆ show_only_active_users()

assign::show_only_active_users ( )

Check is only active users in course should be shown.

Return values
booltrue if only active users should be shown.

◆ show_submit_button()

assign::show_submit_button ( $submission = null,
$teamsubmission = null,
$userid = null )
protected

Returns true if the submit subsission button should be shown to the user.

Parameters
stdClass$submissionThe users own submission record.
stdClass$teamsubmissionThe users team submission record if there is one
int$useridThe user
Return values
bool

◆ submission_empty()

assign::submission_empty ( $submission)

Determine if the current submission is empty or not.

Parameters
submission$submissionthe students submission record to check.
Return values
bool

◆ submissions_open()

assign::submissions_open ( $userid = 0,
$skipenrolled = false,
$submission = false,
$flags = false,
$gradinginfo = false )

Is this assignment open for submissions?

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

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

◆ submit_for_grading()

assign::submit_for_grading ( $data,
$notices )

Submit a submission for grading.

Parameters
stdClass$data- The form data
array$notices- List of error messages to display on an error condition.
Return values
boolReturn false if the submission was not submitted.

◆ unlock_submission()

assign::unlock_submission ( $userid)

Unlock the student submission.

Parameters
int$userid
Return values
bool

◆ update_activity_completion_records()

assign::update_activity_completion_records ( $teamsubmission,
$requireallteammemberssubmit,
$submission,
$userid,
$complete,
$completion )
protected

Updates and creates the completion records in mdl_course_modules_completion.

Parameters
int$teamsubmissionvalue of 0 or 1 to indicate whether this is a group activity
int$requireallteammemberssubmitvalue of 0 or 1 to indicate whether all group members must click Submit
obj$submissionthe submission
int$useridthe user id
int$complete
obj$completion
Return values
null

◆ update_calendar()

assign::update_calendar ( $coursemoduleid)

Update the calendar entries for this assignment.

Parameters
int$coursemoduleid- Required to pass this in because it might not exist in the database yet.
Return values
bool

◆ update_effective_access()

assign::update_effective_access ( $userid)

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.

Parameters
int$useridThe userid.

◆ update_grade()

assign::update_grade ( $grade,
$reopenattempt = false )

Update a grade in the grade table for the assignment and in the gradebook.

Parameters
stdClass$gradea grade record keyed on id
bool$reopenattemptIf the attempt reopen method is manual, allow another attempt at this assignment.
Return values
booltrue for success

◆ update_gradebook()

assign::update_gradebook ( $reset,
$coursemoduleid )

Update the gradebook information for this assignment.

Parameters
bool$resetIf true, will reset all grades in the gradbook for this assignment
int$coursemoduleidThis is required because it might not exist in the database yet
Return values
bool

◆ update_instance()

assign::update_instance ( $formdata)

Update this instance in the database.

Parameters
stdClass$formdata- the data submitted from the form
Return values
boolfalse if an error occurs

◆ update_plugin_instance()

assign::update_plugin_instance ( assign_plugin $plugin,
stdClass $formdata )
protected

Update the settings for a single plugin.

Parameters
assign_plugin$pluginThe plugin to update
stdClass$formdataThe form data
Return values
boolfalse if an error occurs

◆ update_submission()

assign::update_submission ( stdClass $submission,
$userid,
$updatetime,
$teamsubmission )
protected

Update grades in the gradebook based on submission time.

Parameters
stdClass$submission
int$userid
bool$updatetime
bool$teamsubmission
Return values
bool

◆ update_team_submission()

assign::update_team_submission ( stdClass $submission,
$userid,
$updatetime )
protected

Update team submission.

Parameters
stdClass$submission
int$userid
bool$updatetime
Return values
bool

◆ update_user_flags()

assign::update_user_flags ( $flags)

Update user flags for this user in this assignment.

Parameters
stdClass$flagsa flags record keyed on id
Return values
booltrue for success

◆ view()

assign::view ( $action = '',
$args = array() )

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.

Parameters
string$actionThe current action if any.
array$argsOptional arguments to pass to the view (instead of getting them from GET and POST).
Return values
string- The page output.

◆ view_batch_markingallocation()

assign::view_batch_markingallocation ( $mform)

Shows a form that allows the allocated marker for selected submissions to be changed.

Parameters
moodleform$mformSet to a grading batch operations form
Return values
string- the page to view after processing these actions

◆ view_batch_set_workflow_state()

assign::view_batch_set_workflow_state ( $mform)
protected

Shows a form that allows the workflow state for selected submissions to be changed.

Parameters
moodleform$mformSet to a grading batch operations form
Return values
string- the page to view after processing these actions

◆ view_edit_submission_page()

assign::view_edit_submission_page ( $mform,
$notices )
protected

View edit submissions page.

Parameters
moodleform$mform
array$noticesA list of notices to display at the top of the edit submission form (e.g. from plugins).
Return values
stringThe page output.

◆ view_fix_rescaled_null_grades()

assign::view_fix_rescaled_null_grades ( )
protected

View fix rescaled null grades.

Return values
voidThe notifications API will render the notifications at the appropriate part of the page.

◆ view_footer()

assign::view_footer ( )
protected

Display the page footer.

Return values
string

◆ view_grader()

assign::view_grader ( )
protected

View entire grader app.

Return values
string

◆ view_grading_page()

assign::view_grading_page ( )
protected

View entire grading page.

Return values
string

◆ view_grading_table()

assign::view_grading_table ( )
protected

View the grading table of all submissions for this assignment.

Return values
string

◆ view_grant_extension()

assign::view_grant_extension ( $mform)
protected

View the grant extension date page.

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

Parameters
moodleform$mform- Used for validation of the submitted data
Return values
string

◆ view_notices()

assign::view_notices ( $title,
$notices )
protected

Message for students when assignment submissions have been closed.

Parameters
string$titleThe page title
array$noticesThe array of notices to show.
Return values
string

◆ view_plugin_content()

assign::view_plugin_content ( $pluginsubtype)
protected

Display the submission that is used by a plugin.

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

Parameters
string$pluginsubtype
Return values
string

◆ view_plugin_grading_batch_operation()

assign::view_plugin_grading_batch_operation ( $mform)
protected

Allows the plugin to show a batch grading operation page.

Parameters
moodleform$mform
Return values
none

◆ view_plugin_page()

assign::view_plugin_page ( )
protected

View a page rendered by a plugin.

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

Return values
string

◆ view_quickgrading_result()

assign::view_quickgrading_result ( $message)
protected

Display a continue page after quickgrading.

Parameters
string$message- The message to display.
Return values
string

◆ view_remove_submission_confirm()

assign::view_remove_submission_confirm ( )
protected

Show a confirmation page to make sure they want to remove submission data.

Return values
string

◆ view_return_links()

assign::view_return_links ( )
protected

View a link to go back to the previous page.

Uses url parameters returnaction and returnparams.

Return values
string

◆ view_reveal_identities_confirm()

assign::view_reveal_identities_confirm ( )
protected

Show a confirmation page to make sure they want to release student identities.

Return values
string

◆ view_savegrading_result()

assign::view_savegrading_result ( $message)
protected

Display a continue page after grading.

Parameters
string$message- The message to display.
Return values
string

◆ view_single_grade_page()

assign::view_single_grade_page ( $mform)
protected

Print the grading page for a single user submission.

Parameters
moodleform$mform
Return values
string

◆ view_single_grading_panel()

assign::view_single_grading_panel ( $args)
protected

Print the grading page for a single user submission.

Parameters
array$argsOptional args array (better than pulling args from _GET and _POST)
Return values
string

◆ view_student_summary()

assign::view_student_summary ( $user,
$showlinks )

Print 2 tables of information with no action links - the submission summary and the grading summary.

Parameters
stdClass$userthe user to print the report for
bool$showlinks- Return plain text or links to the profile
Return values
string- the html summary

◆ view_submission_action_bar()

assign::view_submission_action_bar ( stdClass $instance,
stdClass $user )

The action bar displayed in the submissions page.

Parameters
stdClass$instanceThe settings for the current instance of this assignment
stdClass$userThe user to print the action bar for
Return values
string

◆ view_submission_page()

assign::view_submission_page ( )
protected

View submissions page (contains details of current submission).

Return values
string

The documentation for this class was generated from the following file: