Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Collects information and methods about feedback completion (either complete.php or show_entries.php) More...
Public Member Functions | |
__construct ($feedback, $cm, $courseid, $iscompleted=false, $completedid=null, $nonanonymouseuserid=null, $userid=0) | |
Constructor. More... | |
can_complete () | |
Checks if user has capability to submit the feedback. More... | |
can_submit () | |
Checks if user is prevented from re-submission. More... | |
can_view_analysis () | |
Checks if current user is able to view feedback on this course. More... | |
check_course_is_mapped () | |
Check whether the feedback is mapped to the given courseid. | |
count_completed_responses ($groupid=0) | |
Counts records from {feedback_completed} table for a given feedback. More... | |
create_completed_tmp_from_last_completed () | |
If user has already completed the feedback, create the temproray values from last completed attempt. More... | |
find_last_completed () | |
Retrieves the last completion record for the current user. More... | |
get_cm () | |
Current course module. More... | |
get_completed () | |
Returns a record from 'feedback_completed' table. More... | |
get_completed_courses () | |
For the frontpage feedback returns the list of courses with at least one completed feedback. More... | |
get_courseid () | |
Id of the current course (for site feedbacks only) More... | |
get_current_completed_tmp () | |
Returns the temporary completion record for the current user or guest session. More... | |
get_feedback () | |
Current feedback. More... | |
get_finished_responses () | |
Retrieves responses from an finished attempt. More... | |
get_item_value ($item) | |
Returns a value stored for this item in the feedback (temporary or not, depending on the mode) More... | |
get_items ($hasvalueonly=false) | |
Get all items in this feedback or this template. More... | |
get_jumpto () | |
Return the jumpto property. More... | |
get_next_page ($gopage, $strictcheck=true) | |
Get the next page for the feedback. More... | |
get_pages () | |
Splits the feedback items into pages. More... | |
get_previous_page ($gopage, $strictcheck=true) | |
Get the previous page for the feedback. More... | |
get_resume_page () | |
Page index to resume the feedback. More... | |
get_templateid () | |
Template id. More... | |
get_unfinished_responses () | |
Retrieves responses from an unfinished attempt. More... | |
is_already_submitted ($anycourseid=false) | |
check for multiple_submit = false. More... | |
is_anonymous () | |
Is this feedback anonymous? More... | |
is_empty () | |
Is the items list empty? More... | |
is_open () | |
Is this feedback open (check timeopen and timeclose) More... | |
just_completed () | |
Check if the feedback was just completed. More... | |
page_after_submit () | |
Returns the formatted text of the page after submit or null if it is not set. More... | |
process_page ($gopage, $gopreviouspage=false) | |
Process a page jump via the mod_feedback_complete_form. More... | |
render_items () | |
Render the form with the questions. More... | |
save_response () | |
Saves the response. More... | |
save_response_tmp ($data) | |
Saves unfinished response to the temporary table. More... | |
set_module_viewed () | |
Mark activity viewed for completion-tracking. More... | |
shuffle_anonym_responses () | |
If there are any new responses to the anonymous feedback, re-shuffle all responses and assign response number to each of them. | |
trigger_module_viewed () | |
Trigger module viewed event. More... | |
Protected Member Functions | |
can_see_item ($item) | |
Can the current user see the item, if dependency is met? More... | |
create_current_completed_tmp () | |
Creates a new record in the 'feedback_completedtmp' table for the current user/guest session. More... | |
delete_completedtmp () | |
Deletes the temporary completed and all related temporary values. | |
dependency_has_error ($item) | |
Dependency condition has an error. More... | |
get_last_completed_page () | |
Returns the last page that has items with the value (i.e. More... | |
get_values ($item=null) | |
Returns all completed values for this feedback or just a value for an item. More... | |
get_values_tmp ($item=null) | |
Returns all temporary values for this feedback or just a value for an item. More... | |
Protected Attributes | |
array | $allcourses |
array | $allitems |
cm_info | $cm |
stdClass | $completed |
stdClass | $completedtmp = null |
int | $courseid = 0 |
course where the feedback is filled. More... | |
stdClass | $feedback |
record from 'feedback' table. More... | |
mod_feedback_complete_form | $form = null |
the form used for completing the feedback | |
bool | $iscompleted = false |
int | $jumpto = null |
the next page the user should jump after processing the form | |
bool | $justcompleted = false |
true when the feedback has been completed during the request | |
int | $templateid |
int | $userid |
stdClass[] | $values = null |
stdClass[] | $valuestmp = null |
Collects information and methods about feedback completion (either complete.php or show_entries.php)
mod_feedback_completion::__construct | ( | $feedback, | |
$cm, | |||
$courseid, | |||
$iscompleted = false , |
|||
$completedid = null , |
|||
$nonanonymouseuserid = null , |
|||
$userid = 0 |
|||
) |
Constructor.
stdClass | $feedback | feedback object |
cm_info | $cm | course module object corresponding to the $feedback (at least one of $feedback or $cm is required) |
int | $courseid | current course (for site feedbacks only) |
bool | $iscompleted | has feedback been already completed? If yes either completedid or userid must be specified. |
int | $completedid | id in the table feedback_completed, may be omitted if userid is specified but it is highly recommended because the same user may have multiple responses to the same feedback for different courses |
int | $nonanonymouseuserid | - Return only anonymous results or specified user's results. If null only anonymous replies will be returned and the $completedid is mandatory. If specified only non-anonymous replies of $nonanonymouseuserid will be returned. |
int | $userid | User id to use for all capability checks, etc. Set to 0 for current user (default). |
mod_feedback_completion::can_complete | ( | ) |
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 can_submit() because even if user has capablity to complete, they may have already submitted feedback and can not re-submit
bool |
|
protected |
Can the current user see the item, if dependency is met?
stdClass | $item |
bool | whether user can see item or not, true if there is no dependency or dependency is met, false if dependent question is visible or broken and further it is either not answered or the dependency is not met, null if dependency is broken. |
mod_feedback_completion::can_submit | ( | ) |
Checks if user is prevented from re-submission.
This must be called after can_complete()
bool |
|
inherited |
Checks if current user is able to view feedback on this course.
bool |
|
inherited |
Counts records from {feedback_completed} table for a given feedback.
If $groupid or $this->courseid is set, the records are filtered by the group/course
int | $groupid |
mixed | array of found completeds otherwise false |
mod_feedback_completion::create_completed_tmp_from_last_completed | ( | ) |
If user has already completed the feedback, create the temproray values from last completed attempt.
stdClass | record from feedback_completedtmp or false if not found |
|
protected |
Creates a new record in the 'feedback_completedtmp' table for the current user/guest session.
stdClass | record from feedback_completedtmp or false if not found |
|
protected |
Dependency condition has an error.
stdClass | $item |
bool |
mod_feedback_completion::find_last_completed | ( | ) |
Retrieves the last completion record for the current user.
stdClass | record from feedback_completed or false if not found |
|
inherited |
Current course module.
stdClass |
mod_feedback_completion::get_completed | ( | ) |
Returns a record from 'feedback_completed' table.
stdClass |
|
inherited |
For the frontpage feedback returns the list of courses with at least one completed feedback.
array | id=>name pairs of courses |
|
inherited |
Id of the current course (for site feedbacks only)
stdClass |
mod_feedback_completion::get_current_completed_tmp | ( | ) |
Returns the temporary completion record for the current user or guest session.
stdClass|false | record from feedback_completedtmp or false if not found |
|
inherited |
Current feedback.
stdClass |
mod_feedback_completion::get_finished_responses | ( | ) |
Retrieves responses from an finished attempt.
array | the responses (from the feedback_value table) |
mod_feedback_completion::get_item_value | ( | $item | ) |
Returns a value stored for this item in the feedback (temporary or not, depending on the mode)
stdClass | $item |
string |
|
inherited |
Get all items in this feedback or this template.
bool | $hasvalueonly | only count items with a value. |
array | of objects from feedback_item with an additional attribute 'itemnr' |
mod_feedback_completion::get_jumpto | ( | ) |
Return the jumpto property.
int | the next page to jump. |
|
protected |
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
array | array of two elements [$lastcompleted, $firstincompleted] |
mod_feedback_completion::get_next_page | ( | $gopage, | |
$strictcheck = true |
|||
) |
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.
int | $gopage | current page |
bool | $strictcheck | when gopage is the user-input value, make sure we do not jump over unanswered questions |
int|null | the index of the next page or null if this is the last page |
mod_feedback_completion::get_pages | ( | ) |
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.
array | array of arrays of items |
mod_feedback_completion::get_previous_page | ( | $gopage, | |
$strictcheck = true |
|||
) |
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.
int | $gopage | current page |
bool | $strictcheck | when gopage is the user-input value, make sure we do not jump over unanswered questions |
int|null | the index of the next page or null if this is the first page with items |
mod_feedback_completion::get_resume_page | ( | ) |
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.
int |
|
inherited |
Template id.
int |
mod_feedback_completion::get_unfinished_responses | ( | ) |
Retrieves responses from an unfinished attempt.
array | the responses (from the feedback_valuetmp table) |
|
protected |
Returns all completed values for this feedback or just a value for an item.
stdClass | $item |
array |
|
protected |
Returns all temporary values for this feedback or just a value for an item.
stdClass | $item |
array |
|
inherited |
check for multiple_submit = false.
if the feedback is global so the courseid must be given
bool | $anycourseid | if true checks if this feedback was submitted in any course, otherwise checks $this->courseid . Applicable to frontpage feedbacks only |
bool | true if the feedback already is submitted otherwise false |
|
inherited |
Is this feedback anonymous?
bool |
|
inherited |
Is the items list empty?
bool |
|
inherited |
Is this feedback open (check timeopen and timeclose)
bool |
mod_feedback_completion::just_completed | ( | ) |
Check if the feedback was just completed.
bool | true if the feedback was just completed. |
|
inherited |
Returns the formatted text of the page after submit or null if it is not set.
string|null |
mod_feedback_completion::process_page | ( | $gopage, | |
$gopreviouspage = false |
|||
) |
Process a page jump via the mod_feedback_complete_form.
This function initializes the form and process the submission.
int | $gopage | the current page |
int | $gopreviouspage | if the user chose to go to the previous page |
string | the url to redirect the user (if any) |
mod_feedback_completion::render_items | ( | ) |
Render the form with the questions.
string | the form rendered |
mod_feedback_completion::save_response | ( | ) |
Saves the response.
The form data has already been stored in the temporary table in 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.
mod_feedback_completion::save_response_tmp | ( | $data | ) |
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 save_response() is called to move response from temporary table to completion table.
stdClass | $data | data from the form mod_feedback_complete_form |
mod_feedback_completion::set_module_viewed | ( | ) |
Mark activity viewed for completion-tracking.
mod_feedback_completion::trigger_module_viewed | ( | ) |
Trigger module viewed event.
|
protectedinherited |
course where the feedback is filled.
For feedbacks that are NOT on the front page this is 0
|
protectedinherited |
record from 'feedback' table.
Reliably has fields: id, course, timeopen, timeclose, anonymous, completionsubmit. For full object or to access any other field use $this->get_feedback()