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

Enrollment duration course completion criteria gets issued at the wrong time

XMLWordPrintable

    • MOODLE_403_STABLE, MOODLE_404_STABLE
    • MOODLE_403_STABLE, MOODLE_404_STABLE
    • MDL-82620-403
    • MDL-82620-404
    • MDL-82620-main
    • Hide

      This issue will either require you to wait over 1 day, or directly manipulate the database to test.

      1. Create a course
      2. In the course completion settings, enable the Enrolment duration condition, set at 1 day.
      3. Enrol a student in the course.
      4. After you create the enrollment, click the gear in the participants report, and change their start date to at least several days in the future.
      5. Wait 24 + hours or...
        Update mdl_user_enrolments, so the timecreated field for this record is at least 2 days in the past. You can do something like:

        UPDATE mdl_user_enrolments SET timecreated = (timecreated - 259200) WHERE userid = 3 AND enrolid = 1
        

      6. Run this completion cron task twice:

        php admin/cli/scheduled_task.php --execute=\\core\\task\\completion_regular_task

      7. Confirm you do not see a log line about marking your test student complete in your test course in either run.
      8. In the database, confirm you don't have a completion criteria for the user in mdl_course_completion_crit_compl for the course you are working in.
      9. In the participants list, change the user's start date to two days in the past.
      10. Run the completion cron 2 more times.
      11. Confirm you see a log line about marking the user as complete in your test course.
      12. Go to the course completion report.
      13. Confirm the user has a checkmark in the 1 day duration column.
      14. Hover over the checkmark, and confirm the reported completion time is correct, which should be approximately 1 day prior to now.
      Show
      This issue will either require you to wait over 1 day, or directly manipulate the database to test. Create a course In the course completion settings, enable the Enrolment duration condition, set at 1 day. Enrol a student in the course. After you create the enrollment, click the gear in the participants report, and change their start date to at least several days in the future. Wait 24 + hours or... Update mdl_user_enrolments , so the timecreated field for this record is at least 2 days in the past. You can do something like: UPDATE mdl_user_enrolments SET timecreated = (timecreated - 259200) WHERE userid = 3 AND enrolid = 1 Run this completion cron task twice: php admin/cli/scheduled_task.php --execute=\\core\\task\\completion_regular_task Confirm you do not see a log line about marking your test student complete in your test course in either run. In the database, confirm you don't have a completion criteria for the user in mdl_course_completion_crit_compl for the course you are working in. In the participants list, change the user's start date to two days in the past. Run the completion cron 2 more times. Confirm you see a log line about marking the user as complete in your test course. Go to the course completion report. Confirm the user has a checkmark in the 1 day duration column. Hover over the checkmark, and confirm the reported completion time is correct, which should be approximately 1 day prior to now.

      Basically it's an interplay with the user enrollment's timestart and ​timecreated. What should be happening is that if the enrollment has a timestart, that should be used as the reference point for the duration. But if there is no timestart, then instead the timecreated value should be used (since it is assumed the started when they were created).

      But what is happening instead, is it is seeing if either timestart or timecreated (plus the duration time) has is in the past, and if either one is, it will mark the criteria complete. And again, because of the incongruity here, it is marking them with the correct completion time, but actually doing it at the wrong time. To hopeful make that more clear, I will use an example:

       
      For this completion criteria, the required duration is 365 days.
      ​On July 2nd 2023, someone created an enrollment record for the user. ​They have a start date of Aug 2nd 2023.
       
      So because of this bug, the completion cron sees them as having completed the duration start on the night of of July 1st 2024, and when cron runs next, it will see them. But, because of how the record is processed, the completion time is correctly marked as being complete on Aug 1st, 2024 (365 days after the start date) - but that is in the future from the point in time that we are creating that completion record.

            emerrill Eric Merrill
            emerrill Eric Merrill
            Darko Miletic Darko Miletic
            Amaia Anabitarte Amaia Anabitarte
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 45 minutes
                2h 45m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.