catalyst / totara-mod-ojt

https://github.com/catalyst/totara-mod-ojt/wiki
5 stars 21 forks source link

Course completion not resetting correctly when recertification window opens #51

Open agwells opened 2 months ago

agwells commented 2 months ago

Here's the scenario. If you have a certification set up, with a recertification window that comes up automatically, then when the recert window opens, Totara should clear the course and activity completion records for the cert's requirements. Specifically, it "archives" them.

The problem is, that for OJT this does not work correctly. After the recert window opens, the activity completion gets cleared correctly, but the course completion does not.

Replication

In brief:

  1. Set up an OJT activity, with activity completion and course completion
  2. Set up a certification that has the OJT activity's course as a requirement
  3. Make the certification have a recertification window that opens up some time after certification
  4. Have a user complete the activity (and thus the course, and thus the certification)
  5. Wait for recertification (or turn the clock forward to cause recertification to be triggered)
    • Expected result: Totara has reset the user's certification, activity completion, and course completion status.
    • Actual result: Totara has reset the user's certification and activity completion. But course completion is not reset.

In detail:

Creating the course, activity, and certification

  1. Do a clean install of Totara, with the mod/ojt plugin installed.
  2. Create a test course
  3. Add an OJT activity to the test course, with activity tracking enabled.
    1. In the activity settings go to the "Activity completion" section
      • Tick "Show activity as complete when conditions are met"
      • Tick "All required topics are complete and, if enabled, witnessed"
  4. Enter the OJT activity and add at least one topic, and at least one required topic item.
  5. Enable course completion for the course
    1. In the course go to "Course administration -> Editing settings -> Completion tracking"
      • Set "Enable completion tracking" to "yes"
      • Set "Due date" to "none"
    2. Go to "Course administration -> Course completion"
      • General
        • Select "Course is complete when ALL conditions are met"
      • Condition: Activity completion
        • Tick the box next to your activity
  6. Create a test learner user
  7. Enrol the learner user in the course with the learner role
  8. Create a certification
    1. Site administration -> Learning -> Certification
      1. Add new certification
      2. Leave all settings (except the name if you want) on default
      3. Click on "Content" tab
        • Certification Content
          • Add a new set of courses
          • Set "Minimum time required" to "No minimum time"
          • Click "Add course" and add your course
        • Recertification Path
          • Tick "Use same..." checkbox
        • Click save
      4. Click on "Certification" tab
        • Active period
          • Certification is active for: set to 3 days
        • Recertification window
          • Period window opens before expiration: set to 2 days (must be less than the certification period)
      5. Click on "Assignments" tab
        • In "Add..." menu, select "Individuals"
          • In the popup, pick your user and add them

Trigger completion and recertification

  1. Log in as admin
  2. Go to the test OJT activity
  3. Click "Evaluate students"
  4. Locate the test learner and click "Evaluate"
  5. Tick the box for their topic item(s) to indicate that they've completed it
  6. This should now have triggered completion. Inspect:
    • Course completion: "(the course) -> Course administration -> Reports -> Course completion"
      • User should show "completed"
    • Activity completion: "(the course) -> Course administration -> Reports -> Activity completion"
      • User should show "completed"
    • Certification: "Site administration -> Learning -> Certifications -> (the category) -> (the certification) -> "Edit certification details" -> "Completion"
      • User should show "certified"
      • Clicking into the users details shows "Certified, before window opens"
  7. Update the certification record in the database so that it's immediately ready for renewal.
    • select * from mdl_certif_completion where userid = ?;
    • update mdl_certif_completion set timewindowopens=floor(extract(epoch from now())) where id = ?;
  8. Run the cron
    • Note: the necessary cron task ("Update certifications") is only scheduled to run once per hour. So if it doesn't run, go to "Site administration -> Server -> Server -> Scheduled tasks" and change its schedule to run every minute.
  9. View the user's activity status, course completion status, and certification status again, as in step 6.
    • Certification: should have changed to "Certified, window is open"
    • Activity completion: not completed
    • Course completion:
      • Expected result: not completed
      • Actual result: completed
agwells commented 2 months ago

See pull request #50