Skip to content

Commit

Permalink
MDL-45127 mod_lesson: Fixed reviewing lesson answers changing the les…
Browse files Browse the repository at this point in the history
…son grade.
  • Loading branch information
abgreeve committed May 2, 2014
1 parent 20685b2 commit 0aec842
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions mod/lesson/continue.php
Expand Up @@ -94,6 +94,8 @@
$attempts = $DB->get_records("lesson_attempts", array("lessonid"=>$lesson->id, "userid"=>$USER->id, "retry"=>$nretakes), "timeseen", "id, pageid");
$found = false;
$temppageid = 0;
// Make sure that the newpageid always defaults to something valid.
$result->newpageid = LESSON_EOL;
foreach($attempts as $attempt) {
if ($found && $temppageid != $attempt->pageid) { // now try to find the next page, make sure next few attempts do no belong to current page
$result->newpageid = $attempt->pageid;
Expand Down
9 changes: 7 additions & 2 deletions mod/lesson/locallib.php
Expand Up @@ -1989,12 +1989,17 @@ final public function record_attempt($context) {

$attempt->timeseen = time();
// if allow modattempts, then update the old attempt record, otherwise, insert new answer record
$userisreviewing = false;
if (isset($USER->modattempts[$this->lesson->id])) {
$attempt->retry = $nretakes - 1; // they are going through on review, $nretakes will be too high
$userisreviewing = true;
}

if ($this->lesson->retake || (!$this->lesson->retake && $nretakes == 0)) {
$DB->insert_record("lesson_attempts", $attempt);
// Only insert a record if we are not reviewing the lesson.
if (!$userisreviewing) {
if ($this->lesson->retake || (!$this->lesson->retake && $nretakes == 0)) {
$DB->insert_record("lesson_attempts", $attempt);
}
}
// "number of attempts remaining" message if $this->lesson->maxattempts > 1
// displaying of message(s) is at the end of page for more ergonomic display
Expand Down

0 comments on commit 0aec842

Please sign in to comment.