MDL-56370 mod_feedback: allow to restore values from last attempt
This commit is contained in:
@@ -401,6 +401,21 @@ class mod_feedback_completion extends mod_feedback_structure {
|
||||
return $this->completedtmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function create_completed_tmp_from_last_completed() {
|
||||
if (!$this->get_current_completed_tmp()) {
|
||||
$lastcompleted = $this->find_last_completed();
|
||||
if ($lastcompleted) {
|
||||
$this->completedtmp = feedback_set_tmp_values($lastcompleted);
|
||||
}
|
||||
}
|
||||
return $this->completedtmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves unfinished response to the temporary table
|
||||
*
|
||||
|
||||
@@ -92,6 +92,7 @@ $cansubmit = $feedbackcompletion->can_submit();
|
||||
|
||||
// Initialise the form processing feedback completion.
|
||||
if (!$feedbackcompletion->is_empty() && $cansubmit) {
|
||||
$feedbackcompletion->create_completed_tmp_from_last_completed();
|
||||
$form = new mod_feedback_complete_form(mod_feedback_complete_form::MODE_COMPLETE,
|
||||
$feedbackcompletion, 'feedback_complete_form', array('gopage' => $gopage));
|
||||
if ($form->is_cancelled()) {
|
||||
|
||||
@@ -1881,8 +1881,6 @@ function feedback_print_item_show_value($item, $value = false) {
|
||||
*/
|
||||
function feedback_set_tmp_values($feedbackcompleted) {
|
||||
global $DB;
|
||||
debugging('Function feedback_set_tmp_values() is deprecated and since it is '
|
||||
. 'no longer used in mod_feedback', DEBUG_DEVELOPER);
|
||||
|
||||
//first we create a completedtmp
|
||||
$tmpcpl = new stdClass();
|
||||
|
||||
Reference in New Issue
Block a user