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

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

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0
    • 1.8.7
    • Forms Library
    • None
    • MOODLE_20_STABLE
    • 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.

      Attachments

        Issue Links

          Activity

            People

              jamiesensei Jamie Pratt
              ppichet Pierre Pichet
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                15/Oct/08