Moodle
  1. Moodle
  2. MDL-24033

Database module allows you to start adding new entries even if the maximum has already been reached

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.9.9
    • Fix Version/s: 1.9.9
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      26094

      Description

      -> As admin, among the settings of an instance of database module, I set: Maximum entries = 1
      -> As student I go to add a record to the database and all is fine
      -> Now, always as the same student, I try to add one more record even if Maximum entries = 1
      -> First weird event: The "Add entry" TAB is still visible.
      -> I proceed to add one more record, I get the form, I fill it and I go to submit it.
      -> At the submit time I get the following message: "You have entered the maximum number of entries allowed!"

      As far as I can I would prevent this behavior. Students should be stopped before filling the form, not after!!!!
      (Forms here, may be hundred fields long and I am helping students to waste their time!)
      I find this behavior not too correct.
      Do you agree?

      1. 2010092302-MDL24033-m20-edit.patch
        1 kB
        Daniele Cordella
      2. 20100923-MDL24033-m19-edit.patch
        2 kB
        Daniele Cordella
      3. edit_m20.patch
        0.6 kB
        Daniele Cordella
      4. edit_newidea.patch
        0.8 kB
        Daniele Cordella
      5. edit.patch
        0.5 kB
        Daniele Cordella
      6. tabs_m20.patch
        0.8 kB
        Daniele Cordella
      7. tabs.patch
        0.8 kB
        Daniele Cordella

        Issue Links

          Activity

          Hide
          Daniele Cordella added a comment - - edited

          As far as I can understand, these patches close the issue.
          Please, review and close this bug.
          Thanks in advance.

          Patches were built on last, just downloaded, moodle 1.9.9 release.

          Show
          Daniele Cordella added a comment - - edited As far as I can understand, these patches close the issue. Please, review and close this bug. Thanks in advance. Patches were built on last, just downloaded, moodle 1.9.9 release.
          Hide
          Martin Dougiamas added a comment -

          Thanks Daniele!

          The patch looks sensible to me, although I have not tested it.

          Apu, can you check this in to 1.9 and 2.0? Make sure you test it.

          Show
          Martin Dougiamas added a comment - Thanks Daniele! The patch looks sensible to me, although I have not tested it. Apu, can you check this in to 1.9 and 2.0? Make sure you test it.
          Hide
          Daniele Cordella added a comment -

          Ciao Martin and thanks for your support.
          During the development of the patch for moodle2 I found the error I reported in MDL-24133.
          I suggest to delay the creation of the patch for moodle2 at the resolution of that bug.

          In the mean time I changed my mind about the patch for moodle 1.9
          At the first time I was exiting the code before the database form was display in case of
          if (data_atmaxentries($data) and !has_capability('mod/data:manageentries',$context)) {
          but now I think this solution is not elegant at all.

          This is my current idea: when the user is submitting his/her last form (last because of Maximum entries) he/she can stlll see the "Save and add another" button even if that button should not be displayed. Moreover, if the button is not displayed, I do not need to exit the code execution before the form displayed again because the student can ONLY submit without adding one more record at the same time.

          This is the reason why I change the edit.patch in the new one that is attached as well.

          Show
          Daniele Cordella added a comment - Ciao Martin and thanks for your support. During the development of the patch for moodle2 I found the error I reported in MDL-24133 . I suggest to delay the creation of the patch for moodle2 at the resolution of that bug. In the mean time I changed my mind about the patch for moodle 1.9 At the first time I was exiting the code before the database form was display in case of if (data_atmaxentries($data) and !has_capability('mod/data:manageentries',$context)) { but now I think this solution is not elegant at all. This is my current idea: when the user is submitting his/her last form (last because of Maximum entries) he/she can stlll see the "Save and add another" button even if that button should not be displayed. Moreover, if the button is not displayed, I do not need to exit the code execution before the form displayed again because the student can ONLY submit without adding one more record at the same time. This is the reason why I change the edit.patch in the new one that is attached as well.
          Hide
          Daniele Cordella added a comment -

          My plan is to make the patch for moodle 2 as soon as MDL-24133 will be fixed.

          Show
          Daniele Cordella added a comment - My plan is to make the patch for moodle 2 as soon as MDL-24133 will be fixed.
          Hide
          Andrea Bicciolo added a comment -

          Committed changes according to discussion.

          Show
          Andrea Bicciolo added a comment - Committed changes according to discussion.
          Hide
          Daniele Cordella added a comment - - edited

          patches for moodle 2 were uploaded

          Show
          Daniele Cordella added a comment - - edited patches for moodle 2 were uploaded
          Hide
          Martin Dougiamas added a comment -

          Great - nice and simple. Please check in

          Show
          Martin Dougiamas added a comment - Great - nice and simple. Please check in
          Hide
          Andrea Bicciolo added a comment -

          Committed the same fix ported on m2.

          Show
          Andrea Bicciolo added a comment - Committed the same fix ported on m2.
          Hide
          Daniele Cordella added a comment - - edited

          during the test I found that all is working fine...

          • BUT -

          the is no control against "direct address input".
          This means that... if user is no longer allowed to add a record but types the address manually, he/she can still get the form to add a record.

          Thiese new patches:
          20100923-MDL24033-m19-edit.patch
          and
          20100923-MDL2403302-m20-edit.patch
          are intended to block this kind of access.

          Show
          Daniele Cordella added a comment - - edited during the test I found that all is working fine... BUT - the is no control against "direct address input". This means that... if user is no longer allowed to add a record but types the address manually, he/she can still get the form to add a record. Thiese new patches: 20100923-MDL24033-m19-edit.patch and 20100923-MDL2403302-m20-edit.patch are intended to block this kind of access.
          Hide
          Andrea Bicciolo added a comment -

          patch committe din 1.9 stable. Please test again before tagging to weekly

          Show
          Andrea Bicciolo added a comment - patch committe din 1.9 stable. Please test again before tagging to weekly

            People

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

              Dates

              • Created:
                Updated:
                Resolved: