MDL-45127 mod_lesson: Fixed reviewing lesson answers changing the lesson grade.

This commit is contained in:
Adrian Greeve 2014-04-24 10:14:13 +08:00
parent 20685b287d
commit 0aec842e58
2 changed files with 9 additions and 2 deletions

View File

@ -94,6 +94,8 @@ if (isset($USER->modattempts[$lesson->id])) {
$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;

View File

@ -1989,12 +1989,17 @@ abstract class lesson_page extends lesson_base {
$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