Moodle
  1. Moodle
  2. MDL-39743

mod/assign: Check 'grantextension' capability before showing "Grant extension" option

    Details

    • Testing Instructions:
      Hide

      Steps to replicate:

      1 Create a tutor role as a clone of editingteacher but with only these

      mod/assign caps:
      mod/assign:exportownsubmission
      mod/assign:grade
      mod/assign:view

      2 Log in as tutor
      3 View assignment submissions
      4 Select one or more submissions
      5 In the “with selected” dropdown list (bottom of submissions table), “grant extension” appears
      6 Choose “grant extension”, then go, then confirm
      7 Enable and choose an extension date
      8 Save changes
      9 Error message is displayed - “Sorry, you do not have permissions to do that (grant extension)”

      Steps to test fix:

      1 Log in as tutor
      2 View assignment submissions
      3 Select one or more submissions
      4 In the “with selected” dropdown list (bottom of submissions table), ensure “grant extension” does not appear

      Show
      Steps to replicate: 1 Create a tutor role as a clone of editingteacher but with only these mod/assign caps: mod/assign:exportownsubmission mod/assign:grade mod/assign:view 2 Log in as tutor 3 View assignment submissions 4 Select one or more submissions 5 In the “with selected” dropdown list (bottom of submissions table), “grant extension” appears 6 Choose “grant extension”, then go, then confirm 7 Enable and choose an extension date 8 Save changes 9 Error message is displayed - “Sorry, you do not have permissions to do that (grant extension)” Steps to test fix: 1 Log in as tutor 2 View assignment submissions 3 Select one or more submissions 4 In the “with selected” dropdown list (bottom of submissions table), ensure “grant extension” does not appear
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-39743-master

      Description

      When viewing assignment submissions, users are given a dropdown to select numerous available actions to perform on the selected submissions. The "grant extension" option shows up regardless of the mod/assign:grantextension capability. If a user without the capability chooses the "grant extension" option, they will will be presented with the form to grant an extension, but when they submit it they will see a capability error and the extension will not be saved.

      I've attached a patch file for 2.4, but it is not necessarily the "proper" way to fix it. To make this fit more into the rest of the code design, perhaps the form definition shouldn't have any capability checks, but instead call to the assignment to add the extension option if its available. eg. $assign->add_extension_elements() or something.

      Patch attached as a starting point.

        Gliffy Diagrams

          Activity

          Hide
          Ashley Holman added a comment -

          FYI - the role that has this bug has these assignment caps set:

          mod/assign:exportownsubmission
          mod/assign:grade
          mod/assign:view

          Show
          Ashley Holman added a comment - FYI - the role that has this bug has these assignment caps set: mod/assign:exportownsubmission mod/assign:grade mod/assign:view
          Hide
          Damyon Wiese added a comment -

          Thanks for the patch Ash, the changes look good.

          I've ported this to 25/master and I'll send it for integration.

          Cheers, Damyon

          Show
          Damyon Wiese added a comment - Thanks for the patch Ash, the changes look good. I've ported this to 25/master and I'll send it for integration. Cheers, Damyon
          Hide
          Damyon Wiese added a comment -

          Note: this was originally reported for 23 also - but that is not correct.

          Show
          Damyon Wiese added a comment - Note: this was originally reported for 23 also - but that is not correct.
          Hide
          Dan Poltawski added a comment - - edited

          Thanks guys, integrated to master, 25 and 24.

          Show
          Dan Poltawski added a comment - - edited Thanks guys, integrated to master, 25 and 24.
          Hide
          Jason Fowler added a comment -

          Works fine Damyon, thanks

          Show
          Jason Fowler added a comment - Works fine Damyon, thanks
          Hide
          Dan Poltawski added a comment -

          Feature: Thanks to our superb contributors
            In order to make Moodle better
            As an integrator
            I need to thank all our contributors
           
            Scenario: Dan thanks you all
              Given I log in as "dan"
              And I see "lots of fixed issues"
              When I follow "Close integrated issues"
              Then I should see "Lots of thanks to all our contributors"
          

          Your changes are upstream

          Show
          Dan Poltawski added a comment - Feature: Thanks to our superb contributors In order to make Moodle better As an integrator I need to thank all our contributors   Scenario: Dan thanks you all Given I log in as "dan" And I see "lots of fixed issues" When I follow "Close integrated issues" Then I should see "Lots of thanks to all our contributors" Your changes are upstream

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: