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

Users cannot see policies that they accepted but are now inactive (all versions are inactive)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a bug
    • Icon: Minor Minor
    • None
    • 4.4
    • Policy
    • MOODLE_404_STABLE

      I'm not sure if this is a bug or not, first I thought it was a feature but after looking at the code I'm not so sure anymore.

      To reproduce this issue:

      1. As admin, go to Site administration > Users > Policy settings. Set "Site policy handler" to "tool_policy".
      2. Go to Site administration > Users > Manage policies and create one policy.
      3. Login as a student and accept the policy.
      4. As the student, go to your profile > Policies and agreements and check that you can see the policy you just accepted.
      5. As admin in the Manage policies page, open the drop down and click "Set status to Inactive".
      6. With the student, refresh the policies page. The policy no longer appears.

      As mentioned above I thought that this was a feature, but when I looked at the code I saw this code:

      if ($policy->versions[0]->status != policy_version::STATUS_ACTIVE) {
          // Add an empty "currentversion" on top.
          $policy->versions = [0 => (object)[]] + $policy->versions;
      }

      This code doesn't seem to be working as expected, after this code the versions array only had one element (the empty one) and the other version disappeared. 

      I tried changing the code to use array_unshift to properly add the empty version at the start of the array. After doing this, the inactive version appeared in the DOM, but it was hidden because archived versions have "display: none" by default. And the "empty version" on top isn't rendered because it doesn't have an agreement

      Looking at the code, I think this "empty version" was added to display an empty row with the "drop down" button to display older versions. This button would allow viewing this policy that was accepted and then converted to Inactive. But there was a bug in this code, which caused that the drop down button doesn't appear in the UI, you just have an empty row. So this empty row was removed from the DOM in MDL-62281.

            Unassigned Unassigned
            dpalou Dani Palou
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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