Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-53532

completion_criteria_course wrong timecompleted

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.0
    • None
    • Course completion
    • MOODLE_30_STABLE
    • Easy

    Description

      The criterion during review, does not take into account the completion time of course it is checking, instead it applies current time.
      Affected method:

       public function review($completion, $mark = true) {
              global $DB;
       
              $course = $DB->get_record('course', array('id' => $this->courseinstance));
              $info = new completion_info($course);
       
              // If the course is complete
              if ($info->is_course_complete($completion->userid)) {
       
                  if ($mark) {
                      $completion->mark_complete();
                  }
       
                  return true;
              }
       
              return false;
          }
      

      And a simple fix:

      public function review($completion, $mark = true) {
              global $DB;
       
              $course = $DB->get_record('course', array('id' => $this->courseinstance));
              $info = new completion_info($course);
       
              // If the course is complete
              if ($info->is_course_complete($completion->userid)) {
       
                  if ($mark) {
                      $cc = new completion_completion(['userid'=>$completion->userid,'course'=>$course->id]);
                      $completion->mark_complete($cc->timecompleted);
                  }
       
                  return true;
              }
       
              return false;
          }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              artur.poninski Artur Poniński
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: