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

Details

    • MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE
    • Hide
      • 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)

       

      Show
      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)  

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              emerrill Eric Merrill
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:

                Clockify

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