MDL-48715 mod_lesson: completion rules must not be dependent
authorJean-Michel Vedrine <vedrine@vedrine.org>
Wed, 18 Mar 2015 09:10:48 +0000 (10:10 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 19 Mar 2015 11:24:55 +0000 (12:24 +0100)
mod/lesson/lang/en/lesson.php
mod/lesson/locallib.php
mod/lesson/view.php

index 29988ab..8fc15a4 100644 (file)
@@ -97,7 +97,7 @@ $string['completederror'] = 'Complete the lesson';
 $string['completethefollowingconditions'] = 'You must complete the following condition(s) in <b>{$a}</b> 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['completethefollowingconditions'] = 'You must complete the following condition(s) in <b>{$a}</b> 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';
 $string['completiontimespentgroup'] = 'Require time spent';
 $string['conditionsfordependency'] = 'Condition(s) for the dependency';
 $string['configactionaftercorrectanswer'] = 'The default action to take after a correct answer';
index 47d7ac6..8832444 100644 (file)
@@ -1278,6 +1278,15 @@ class lesson extends lesson_base {
         $timer->lessontime = time();
         $timer->completed = $endreached;
         $DB->update_record('lesson_timer', $timer);
         $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;
     }
 
         return $timer;
     }
 
index 11e1ecf..106950c 100644 (file)
@@ -458,7 +458,7 @@ if ($pageid != LESSON_EOL) {
 
         // Update completion state.
         $completion = new completion_info($course);
 
         // 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);
         }
 
             $completion->update_state($cm, COMPLETION_COMPLETE);
         }