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

Activity completion Report - Course modules can get marked as view even when they aren't viewed.

XMLWordPrintable

    • MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE, MOODLE_404_STABLE
    • MOODLE_403_STABLE, MOODLE_404_STABLE
    • MDL-79971-403
    • MDL-79971-404
    • MDL-79971-main
    • Hide
      • Changes cover by PHPunit tests.

      Manual testing:

      1. Create a course C1
      2. Add an assignment A1 and set the Make a submission as completion criteria
      3. Enrol user S1
      4. Go to Report / Activity completion
      5. Check that the course_module_viewed has no row related to this module
      6. Mark the activity as complete (as a teacher)
      7. Check that the course_module_viewed has no row related to this module
      8. Unmark it
      9. Ensure that the course_module_viewed has no row related to this module (before was failing as a record was inserted)

       

      Show
      Changes cover by PHPunit tests. Manual testing: Create a course C1 Add an assignment A1 and set the Make a submission as completion criteria Enrol user S1 Go to Report / Activity completion Check that the course_module_viewed has no row related to this module Mark the activity as complete (as a teacher) Check that the course_module_viewed has no row related to this module Unmark it Ensure that the course_module_viewed has no row related to this module (before was failing as a record was inserted)  
    • 2
    • HQ 2024 Sprint I2.2 Moppies

      In MDL-58266, a new course module view tracking table was added. But in some cases, a viewed entry can be added, even when it shouldn't be. Specifically if completion_info->update_state() is called some cases.

      To recreate:

      1. Have a course with some students in it.
      2. Create an activity in that course with some form of activity completion enabled (it doesn't have to be 'viewed').
      3. Look in the course_modules_viewed table for the course module you just created, and confirm it has no records in it for your test user(s).
      4. In the activity completion report, mark the activity as complete for a user.
      5. If you inspect the DB again, still won't see a viewed record.
      6. Now, for that same user, click to un-complete that activity for the user.
      7. Now if you check in the database, you will see that the user got a 'viewed' record added, even though that user never viewed the completion.

      This specifically seems to happen when update_state() is called, and the user has a module completion record, but it is not in a complete state. From what I can tell, this is all because completion_info->get_completion_data() added in MDL-5826. It seems to assume that a user can't have a completion state in an activity if they haven't viewed it - so if they do have a completion state (whether completed or not), they must have viewed it, which is incorrect.

      Basically, the first part of the query will return a row if there is a course_modules_completion has a record in it - even if no viewed record is present. And the function then assumes if a row was returned from that statement, then it must have been viewed - rather than checking the actual returned value. That viewed = 1 then gets gets passed to internal_set_data(), which creates the viewed record, because it doesn't exist.

      I haven't tested it, but I'm pretty sure the line:

      $data->viewed = 1; 

      Needs to be replaced with something like:

      $data->viewed = empty($data->cmvuserid) ? 0 : 1;

      (and moving the unsets down).

       

      Note that while the given example above is somewhat niche, I found this while digging into an issue in reset code found in Moodle Workplace.

            amaia Amaia Anabitarte
            emerrill Eric Merrill
            Eric Merrill Eric Merrill
            Ferran Recio Ferran Recio
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 5 minutes
                1h 5m

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