Search moodle.org's
Developer Documentation

See Release Notes

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

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

Contains class mod_feedback_completion

Copyright: 2016 Marina Glancy
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 762 lines (29 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: mod_feedback_completion  - X-Ref

Collects information and methods about feedback completion (either complete.php or show_entries.php)

__construct($feedback, $cm, $courseid, $iscompleted = false, $completedid = null,$nonanonymouseuserid = null, $userid = 0)   X-Ref
Constructor

param: stdClass $feedback feedback object
param: cm_info $cm course module object corresponding to the $feedback
param: int $courseid current course (for site feedbacks only)
param: bool $iscompleted has feedback been already completed? If yes either completedid or userid must be specified.
param: int $completedid id in the table feedback_completed, may be omitted if userid is specified
param: int $nonanonymouseuserid - Return only anonymous results or specified user's results.
param: int $userid User id to use for all capability checks, etc. Set to 0 for current user (default).

get_completed()   X-Ref
Returns a record from 'feedback_completed' table

return: stdClass

just_completed()   X-Ref
Check if the feedback was just completed.

return: bool true if the feedback was just completed.

get_jumpto()   X-Ref
Return the jumpto property.

return: int the next page to jump.

get_current_completed_tmp()   X-Ref
Returns the temporary completion record for the current user or guest session

return: stdClass|false record from feedback_completedtmp or false if not found

can_see_item($item)   X-Ref
Can the current user see the item, if dependency is met?

param: stdClass $item
return: bool whether user can see item or not,

dependency_has_error($item)   X-Ref
Dependency condition has an error

param: stdClass $item
return: bool

get_item_value($item)   X-Ref
Returns a value stored for this item in the feedback (temporary or not, depending on the mode)

param: stdClass $item
return: string

get_unfinished_responses()   X-Ref
Retrieves responses from an unfinished attempt.

return: array the responses (from the feedback_valuetmp table)

get_values_tmp($item = null)   X-Ref
Returns all temporary values for this feedback or just a value for an item

param: stdClass $item
return: array

get_finished_responses()   X-Ref
Retrieves responses from an finished attempt.

return: array the responses (from the feedback_value table)

get_values($item = null)   X-Ref
Returns all completed values for this feedback or just a value for an item

param: stdClass $item
return: array

get_pages()   X-Ref
Splits the feedback items into pages

Items that we definitely know at this stage as not applicable are excluded.
Items that are dependent on something that has not yet been answered are
still present, as well as items with broken dependencies.

return: array array of arrays of items

get_last_completed_page()   X-Ref
Returns the last page that has items with the value (i.e. not label) which have been answered
as well as the first page that has items with the values that have not been answered.

Either of the two return values may be null if there are no answered page or there are no
unanswered pages left respectively.

Two pages may not be directly following each other because there may be empty pages
or pages with information texts only between them

return: array array of two elements [$lastcompleted, $firstincompleted]

get_next_page($gopage, $strictcheck = true)   X-Ref
Get the next page for the feedback

This is normally $gopage+1 but may be bigger if there are empty pages or
pages without visible questions.

This method can only be called when questions on the current page are
already answered, otherwise it may be inaccurate.

param: int $gopage current page
param: bool $strictcheck when gopage is the user-input value, make sure we do not jump over unanswered questions
return: int|null the index of the next page or null if this is the last page

get_previous_page($gopage, $strictcheck = true)   X-Ref
Get the previous page for the feedback

This is normally $gopage-1 but may be smaller if there are empty pages or
pages without visible questions.

param: int $gopage current page
param: bool $strictcheck when gopage is the user-input value, make sure we do not jump over unanswered questions
return: int|null the index of the next page or null if this is the first page with items

get_resume_page()   X-Ref
Page index to resume the feedback

When user abandones answering feedback and then comes back to it we should send him
to the first page after the last page he fully completed.
return: int

create_current_completed_tmp()   X-Ref
Creates a new record in the 'feedback_completedtmp' table for the current user/guest session

return: stdClass record from feedback_completedtmp or false if not found

create_completed_tmp_from_last_completed()   X-Ref
If user has already completed the feedback, create the temproray values from last completed attempt

return: stdClass record from feedback_completedtmp or false if not found

save_response_tmp($data)   X-Ref
Saves unfinished response to the temporary table

This is called when user proceeds to the next/previous page in the complete form
and also right after the form submit.
After the form submit the {@link save_response()} is called to
move response from temporary table to completion table.

param: stdClass $data data from the form mod_feedback_complete_form

save_response()   X-Ref
Saves the response

The form data has already been stored in the temporary table in
{@link save_response_tmp()}. This function copies the values
from the temporary table to the completion table.
It is also responsible for sending email notifications when applicable.

delete_completedtmp()   X-Ref
Deletes the temporary completed and all related temporary values


find_last_completed()   X-Ref
Retrieves the last completion record for the current user

return: stdClass record from feedback_completed or false if not found

can_complete()   X-Ref
Checks if user has capability to submit the feedback

There is an exception for fully anonymous feedbacks when guests can complete
feedback without the proper capability.

This should be followed by checking {@link can_submit()} because even if
user has capablity to complete, they may have already submitted feedback
and can not re-submit

return: bool

can_submit()   X-Ref
Checks if user is prevented from re-submission.

This must be called after {@link can_complete()}

return: bool

trigger_module_viewed()   X-Ref
Trigger module viewed event.


set_module_viewed()   X-Ref
Mark activity viewed for completion-tracking.


process_page($gopage, $gopreviouspage = false)   X-Ref
Process a page jump via the mod_feedback_complete_form.

This function initializes the form and process the submission.

param: int $gopage         the current page
param: int $gopreviouspage if the user chose to go to the previous page
return: string the url to redirect the user (if any)

render_items()   X-Ref
Render the form with the questions.

return: string the form rendered