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

Adding group element in function lib/formslib.php/repeat_elements()

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 1.8.7
    • Component/s: Forms Library
    • Labels:
      None
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE

      Description

      Adding group element to the function lib/formslib.php/repeat_elements() would improve its flexibility.
      Developping an improved question units interface MDL-4474 shows the limit of the actual function.
      The group element sructure is more complex than the single element (i.e. text ) and the first difficulty is related to the creation of the multiple elements step
      Actual code use clone() to create the copy.
      Internal element are not copied and all the cloned group element refers to the original internal element.
      clone()should be replaced by fullclone().
      RCS file: /cvsroot/moodle/moodle/lib/formslib.php,v
      retrieving revision 1.160
      diff -u -r1.160 formslib.php
      — formslib.php 23 Sep 2008 14:45:58 -0000 1.160
      +++ formslib.php 9 Oct 2008 04:59:26 -0000
      @@ -736,7 +736,7 @@
      $mform->setConstants(array($repeathiddenname=>$repeats));
      for ($i=0; $i<$repeats; $i++) {
      foreach ($elementobjs as $elementobj){

      • $elementclone = clone($elementobj);
        + $elementclone = fullclone($elementobj);
        $name = $elementclone->getName();
        if (!empty($name)){
        $elementclone->setName($name."[$i]");
        Other repeated elements functions should also be tested.
        The work on question units will be used to test if other code improvments are necessary.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    15/Oct/08