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

After recalculating activity completion data, completion date should remain unchanged

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • Future Dev
    • Activity completion

      Edited to add issue description summary:

      If you unlock completion settings for an activity then save changes so the completion data is deleted and recalculated, the completion date for each student should remain as the actual date that they completed the activity.

      Steps to reproduce:

      1. Create an activity with completion conditions.
      2. Log in as a student and complete the activity.
      3. Log in as a teacher and go to the activity completion report.
      4. Note the date and time that the student completed the activity, as shown in the table cell tooltip.
      5. Go to the activity settings, unlock the completion settings then save.
      6. Go back to the activity completion report and check the date and time shown in the table cell tooltip.

      Expected result: The date and time should remain as the actual date and time that the student completed the activity.

      Actual result: The date and time is when the activity settings page was saved (and the completion data was deleted and recalculated).


      Original issue description:

      Change in activity completion settings changes existing user activity completion date to the current date instead of the real date when the completion state was saved. To make it easy to understand, I give a description for mod_scorm here but the better is a  solution thatshould works for any activity. i.e, a method in the interface that can be implemented in each module. 

      For mod_scorm, if one unlocks and changes completion criteria, the corresponding records in course_modules_completion will be deleted and new completionstate recalculated based on new criterias. New records that will be added
      to the course_modules_completion table will have the current date as completion date. This doesn't fit reality for existing data. The better would be to set the completion date (timemodified in course_modules_completion) whith the real date when the completionstate was saved. For scorm with custom rules, that's the most recent date when the last criteria were met.

      To fix the issue, one can improve the query of the method get_state() in mod/scorm/classes/completition/custom_completion.php to get the status date that will be set in course_modules_completion. Since get_state() is defined in the interface activity_custom_completion of completion/classes/activity_custom_completion.php  and should return only the status as an integer, a solution can be to add a new method as follow:
      abstract public function get_state_info(string $rule) : array;
      This way, one can return the state and date when the rule is satisfied.

      To use this date, we need to update lib/completionlib.php in the following manner:

      method: get_other_cm_completion_data

      for mod_scorm, we call get_state_info instead of get_state and, if date is set, add it to $data array with the key 'customcompletiontimemodified'

      For update_state method:
      in the case of we need to check for the completion date from the array returned by get_other_cm_completion_data. If there is one, set the activity completion date (in course_modules_completion) to the value received in the array from get_other_cm_completion_data (array key: 'customcompletiontimemodified'). 

      How to test the issue:

      1. create an activity wth completion rules. Lets a say a scorm returning 'completed' status

      2. login as as student and complete the activity

      3.  As a teacher, check the completion date

      4. As a teacher, unlock completions settings and save again

      5. Check that the activity completion date of the student  changed

            jtsheke Johnny Tsheke
            jtsheke Johnny Tsheke
            Votes:
            5 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:

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