MDL-56370 mod_feedback: allow to restore values from last attempt

This commit is contained in:
Marina Glancy
2017-04-05 16:08:27 +08:00
parent 3f48012eb5
commit af6a891144
3 changed files with 16 additions and 2 deletions
+15
View File
@@ -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
*
+1
View File
@@ -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()) {
-2
View File
@@ -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();