From 4b570f714475bacc20d3cfab2ff25391ee07e5ba Mon Sep 17 00:00:00 2001 From: Jean-Michel Vedrine Date: Wed, 18 Mar 2015 10:10:48 +0100 Subject: [PATCH] MDL-48715 mod_lesson: completion rules must not be dependent --- mod/lesson/lang/en/lesson.php | 2 +- mod/lesson/locallib.php | 9 +++++++++ mod/lesson/view.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mod/lesson/lang/en/lesson.php b/mod/lesson/lang/en/lesson.php index 29988ab5674..8fc15a46cec 100644 --- a/mod/lesson/lang/en/lesson.php +++ b/mod/lesson/lang/en/lesson.php @@ -97,7 +97,7 @@ $string['completederror'] = 'Complete the lesson'; $string['completethefollowingconditions'] = 'You must complete the following condition(s) in {$a} lesson before you can proceed.'; $string['completionendreached'] = 'Require end reached'; $string['completionendreached_desc'] = 'Student must reach the end of lesson page to complete this activity'; -$string['completiontimespent'] = 'Student must do this activity for'; +$string['completiontimespent'] = 'Student must do this activity at least for'; $string['completiontimespentgroup'] = 'Require time spent'; $string['conditionsfordependency'] = 'Condition(s) for the dependency'; $string['configactionaftercorrectanswer'] = 'The default action to take after a correct answer'; diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 47d7ac6b93e..88324448019 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -1278,6 +1278,15 @@ class lesson extends lesson_base { $timer->lessontime = time(); $timer->completed = $endreached; $DB->update_record('lesson_timer', $timer); + + // Update completion state. + $cm = get_coursemodule_from_instance('lesson', $this->properties()->id, $this->properties()->course, + false, MUST_EXIST); + $course = get_course($cm->course); + $completion = new completion_info($course); + if ($completion->is_enabled($cm) && $this->properties()->completiontimespent > 0) { + $completion->update_state($cm, COMPLETION_COMPLETE); + } return $timer; } diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 11e1ecfb158..106950c6260 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -458,7 +458,7 @@ if ($pageid != LESSON_EOL) { // Update completion state. $completion = new completion_info($course); - if ($completion->is_enabled($cm) && ($lesson->completionendreached || $lesson->completiontimespent > 0)) { + if ($completion->is_enabled($cm) && $lesson->completionendreached) { $completion->update_state($cm, COMPLETION_COMPLETE); }