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

completion_criteria_course wrong timecompleted

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.0
    • Fix Version/s: None
    • Component/s: Course completion
    • Labels:
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_30_STABLE

      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

              Assignee:
              Unassigned Unassigned
              Reporter:
              artur.poninski Artur Poniński
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated: