Permalink
Browse files

Merge branch 'MDL-32062_22' of git://github.com/timhunt/moodle into M…

…OODLE_22_STABLE
  • Loading branch information...
2 parents dcce217 + f542922 commit c0c6e7966e62fbefefce4504d23818fa92678adf Sam Hemelryk committed Jul 3, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 question/engine/questionattempt.php
View
17 question/engine/questionattempt.php
@@ -1086,15 +1086,32 @@ public function regrade(question_attempt $oldqa, $finished) {
$first = true;
foreach ($oldqa->get_step_iterator() as $step) {
$this->observer->notify_step_deleted($step, $this);
+
if ($first) {
+ // First step of the attempt.
$first = false;
$this->start($oldqa->behaviour, $oldqa->get_variant(), $step->get_all_data(),
$step->get_timecreated(), $step->get_user_id(), $step->get_id());
+
+ } else if ($step->has_behaviour_var('finish') && count($step->get_submitted_data()) > 1) {
+ // This case relates to MDL-32062. The upgrade code from 2.0
+ // generates attempts where the final submit of the question
+ // data, and the finish action, are in the same step. The system
+ // cannot cope with that, so convert the single old step into
+ // two new steps.
+ $submitteddata = $step->get_submitted_data();
+ unset($submitteddata['-finish']);
+ $this->process_action($submitteddata,
+ $step->get_timecreated(), $step->get_user_id(), $step->get_id());
+ $this->finish($step->get_timecreated(), $step->get_user_id());
+
} else {
+ // This is the normal case. Replay the next step of the attempt.
$this->process_action($step->get_submitted_data(),
$step->get_timecreated(), $step->get_user_id(), $step->get_id());
}
}
+
if ($finished) {
$this->finish();
}

0 comments on commit c0c6e79

Please sign in to comment.