Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-38012 META: Simplify moodle forms
  3. MDL-24640

Change interface of repeat_elements to decouple function arguments from elements, added to the form by it

XMLWordPrintable

    • MOODLE_20_STABLE, MOODLE_25_STABLE
    • MDL-24640-repeat_elements-prefix
    • Hide

      Testing instructions:
      Automatic tests:
      Run unit tests for /lib/formslib.php (class core_formslib_testcase)

      Manual checking that all calls of function repeat_elements working correctly with new interface (optional, do as much as you want)

      Preparation:
      0. Log in as editing teacher.
      1. Create 1 course with the name ‘course1’.
      2. Go to 'course1'
      3. Go to 'Question bank'

      Test for question "Multiple choice":
      0. Press button 'Create a new question ...'
      1. Choose 'Multiple choice'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form'
      4. Press button 'Add 3 choice(s) to form'
      5. Make sure you can see 3 new answers
      6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      7. Press button 'Add 1 hint(s) to form'
      8. Make sure you can see a new hint

      Test for question "Matching":
      0. Press button 'Create a new question ...'
      1. Choose 'Matching'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form'
      4. Press button 'Add 3 choice(s) to form'
      5. Make sure you can see 3 new answers
      6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      7. Press button 'Add 1 hint(s) to form'
      8. Make sure you can see a new hint

      Test for question "Short answer":
      0. Press button 'Create a new question ...'
      1. Choose 'Short answer'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form'
      4. Press button 'Add 3 choice(s) to form'
      5. Make sure you can see 3 new answers
      6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      7. Press button 'Add 1 hint(s) to form'
      8. Make sure you can see a new hint

      Test for question "Numerical":
      0. Press button 'Create a new question ...'
      1. Choose 'Numerical'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form'
      4. Press button 'Add 3 choice(s) to form'
      5. Make sure you can see a 3 new answers
      6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      7. Press button 'Add 1 hint(s) to form'
      8. Make sure you can see a new hint
      9. Make sure you can see a list of 'Units' and button 'Add 2 unit(s) to form'
      10. Press button 'Add 2 unit(s) to form'
      11. Make sure you can see 2 new units

      Test for question "Calculated":
      0. Press button 'Create a new question ...'
      1. Choose 'Calculated'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form'
      4. Press button 'Add 3 choice(s) to form'
      5. Make sure you can see 3 new answers
      6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      7. Press button 'Add 1 hint(s) to form'
      8. Make sure you can see a new hint
      9. Make sure you can see a list of 'Units' and button 'Add 2 unit(s) to form'
      10. Press button 'Add 2 unit(s) to form'
      11. Make sure you can see 2 new units

      Test for question "Calculated multichoice":
      0. Press button 'Create a new question ...'
      1. Choose 'Calculated multichoice'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form'
      4. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      4. Press button 'Add 3 choice(s) to form'
      5. Make sure you can see 3 new answers
      6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      7. Press button 'Add 1 hint(s) to form'
      8. Make sure you can see a new hint

      Test for question "Calculated simple":
      0. Press button 'Create a new question ...'
      1. Choose 'Calculated simple'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form'
      4. Press button 'Add 3 choice(s) to form'
      5. Make sure you can see 3 new answers
      6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      7. Press button 'Add 1 hint(s) to form'
      8. Make sure you can see a new hint
      9. Make sure you can see a list of 'Units' and button 'Add 2 unit(s) to form'
      10. Press button 'Add 2 unit(s) to form'
      11. Make sure you can see 3 new units

      Test for question "Drag and drop into text":
      0. Press button 'Create a new question ...'
      1. Choose 'Drag and drop into text'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Choices' and button 'Add 3 choice(s) to form'
      4. Press button 'Add 3 choice(s) to form'
      5. Make sure you can see 3 new answers
      6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      7. Press button 'Add 1 hint(s) to form'
      8. Make sure you can see a new hint

      Test for question "Drag and drop markers":
      0. Press button 'Create a new question ...'
      1. Choose 'Drag and drop markers'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Markers' and button 'Add 3 marker(s) to form'
      4. Press button 'Add 3 marker(s) to form'
      5. Make sure you can see 3 new markers
      6. Make sure you can see a list of 'Drop zones' and button 'Add 3 drop zone(s) to form'
      7. Press button 'Add 3 drop zone(s) to form'
      8. Make sure you can see 3 new drop zones
      9. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      10. Press button 'Add 1 hint(s) to form'
      11. Make sure you can see a new hint

      Test for question "Drag and drop image":
      0. Press button 'Create a new question ...'
      1. Choose 'Drag and drop image'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Markers' and button 'Add 3 marker(s) to form'
      4. Press button 'Add 3 marker(s) to form'
      5. Make sure you can see 3 new markers
      6. Make sure you can see a list of 'Drop zones' and button 'Add 3 drop zone(s) to form'
      7. Press button 'Add 3 drop zone(s) to form'
      8. Make sure you can see 3 new drop zones
      9. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      10. Press button 'Add 1 hint(s) to form'
      11. Make sure you can see a new hint

      Test for question "Embedded answers":
      0. Press button 'Create a new question ...'
      1. Choose 'Embedded answers'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      4. Press button 'Add 1 hint(s) to form'
      5. Make sure you can see a new hint

      Test for question "Random short-answer matching":
      0. Press button 'Create a new question ...'
      1. Choose 'Random short-answer matching'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      4. Press button 'Add 1 hint(s) to form'
      5. Make sure you can see a new hint

      Test for question "Select missing words question":
      0. Press button 'Create a new question ...'
      1. Choose 'Select missing words question'
      2. Press button 'Add'
      3. Make sure you can see a list of 'Choices' and button 'Add 3 choice(s) to form'
      4. Press button 'Add 3 choice(s) to form'
      5. Make sure you can see 3 new choices
      6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form'
      7. Press button 'Add 1 hint(s) to form'
      8. Make sure you can see a new hint

      Show
      Testing instructions: Automatic tests: Run unit tests for /lib/formslib.php (class core_formslib_testcase) Manual checking that all calls of function repeat_elements working correctly with new interface (optional, do as much as you want) Preparation: 0. Log in as editing teacher. 1. Create 1 course with the name ‘course1’. 2. Go to 'course1' 3. Go to 'Question bank' Test for question "Multiple choice": 0. Press button 'Create a new question ...' 1. Choose 'Multiple choice' 2. Press button 'Add' 3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form' 4. Press button 'Add 3 choice(s) to form' 5. Make sure you can see 3 new answers 6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 7. Press button 'Add 1 hint(s) to form' 8. Make sure you can see a new hint Test for question "Matching": 0. Press button 'Create a new question ...' 1. Choose 'Matching' 2. Press button 'Add' 3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form' 4. Press button 'Add 3 choice(s) to form' 5. Make sure you can see 3 new answers 6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 7. Press button 'Add 1 hint(s) to form' 8. Make sure you can see a new hint Test for question "Short answer": 0. Press button 'Create a new question ...' 1. Choose 'Short answer' 2. Press button 'Add' 3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form' 4. Press button 'Add 3 choice(s) to form' 5. Make sure you can see 3 new answers 6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 7. Press button 'Add 1 hint(s) to form' 8. Make sure you can see a new hint Test for question "Numerical": 0. Press button 'Create a new question ...' 1. Choose 'Numerical' 2. Press button 'Add' 3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form' 4. Press button 'Add 3 choice(s) to form' 5. Make sure you can see a 3 new answers 6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 7. Press button 'Add 1 hint(s) to form' 8. Make sure you can see a new hint 9. Make sure you can see a list of 'Units' and button 'Add 2 unit(s) to form' 10. Press button 'Add 2 unit(s) to form' 11. Make sure you can see 2 new units Test for question "Calculated": 0. Press button 'Create a new question ...' 1. Choose 'Calculated' 2. Press button 'Add' 3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form' 4. Press button 'Add 3 choice(s) to form' 5. Make sure you can see 3 new answers 6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 7. Press button 'Add 1 hint(s) to form' 8. Make sure you can see a new hint 9. Make sure you can see a list of 'Units' and button 'Add 2 unit(s) to form' 10. Press button 'Add 2 unit(s) to form' 11. Make sure you can see 2 new units Test for question "Calculated multichoice": 0. Press button 'Create a new question ...' 1. Choose 'Calculated multichoice' 2. Press button 'Add' 3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form' 4. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 4. Press button 'Add 3 choice(s) to form' 5. Make sure you can see 3 new answers 6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 7. Press button 'Add 1 hint(s) to form' 8. Make sure you can see a new hint Test for question "Calculated simple": 0. Press button 'Create a new question ...' 1. Choose 'Calculated simple' 2. Press button 'Add' 3. Make sure you can see a list of 'Answers' and button 'Add 3 choice(s) to form' 4. Press button 'Add 3 choice(s) to form' 5. Make sure you can see 3 new answers 6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 7. Press button 'Add 1 hint(s) to form' 8. Make sure you can see a new hint 9. Make sure you can see a list of 'Units' and button 'Add 2 unit(s) to form' 10. Press button 'Add 2 unit(s) to form' 11. Make sure you can see 3 new units Test for question "Drag and drop into text": 0. Press button 'Create a new question ...' 1. Choose 'Drag and drop into text' 2. Press button 'Add' 3. Make sure you can see a list of 'Choices' and button 'Add 3 choice(s) to form' 4. Press button 'Add 3 choice(s) to form' 5. Make sure you can see 3 new answers 6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 7. Press button 'Add 1 hint(s) to form' 8. Make sure you can see a new hint Test for question "Drag and drop markers": 0. Press button 'Create a new question ...' 1. Choose 'Drag and drop markers' 2. Press button 'Add' 3. Make sure you can see a list of 'Markers' and button 'Add 3 marker(s) to form' 4. Press button 'Add 3 marker(s) to form' 5. Make sure you can see 3 new markers 6. Make sure you can see a list of 'Drop zones' and button 'Add 3 drop zone(s) to form' 7. Press button 'Add 3 drop zone(s) to form' 8. Make sure you can see 3 new drop zones 9. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 10. Press button 'Add 1 hint(s) to form' 11. Make sure you can see a new hint Test for question "Drag and drop image": 0. Press button 'Create a new question ...' 1. Choose 'Drag and drop image' 2. Press button 'Add' 3. Make sure you can see a list of 'Markers' and button 'Add 3 marker(s) to form' 4. Press button 'Add 3 marker(s) to form' 5. Make sure you can see 3 new markers 6. Make sure you can see a list of 'Drop zones' and button 'Add 3 drop zone(s) to form' 7. Press button 'Add 3 drop zone(s) to form' 8. Make sure you can see 3 new drop zones 9. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 10. Press button 'Add 1 hint(s) to form' 11. Make sure you can see a new hint Test for question "Embedded answers": 0. Press button 'Create a new question ...' 1. Choose 'Embedded answers' 2. Press button 'Add' 3. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 4. Press button 'Add 1 hint(s) to form' 5. Make sure you can see a new hint Test for question "Random short-answer matching": 0. Press button 'Create a new question ...' 1. Choose 'Random short-answer matching' 2. Press button 'Add' 3. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 4. Press button 'Add 1 hint(s) to form' 5. Make sure you can see a new hint Test for question "Select missing words question": 0. Press button 'Create a new question ...' 1. Choose 'Select missing words question' 2. Press button 'Add' 3. Make sure you can see a list of 'Choices' and button 'Add 3 choice(s) to form' 4. Press button 'Add 3 choice(s) to form' 5. Make sure you can see 3 new choices 6. Make sure you can see a list of 'Multiple tries' and button 'Add 1 hint(s) to form' 7. Press button 'Add 1 hint(s) to form' 8. Make sure you can see a new hint

      repeat_elements function now receives two arguments, defining elements name for it to add (i.e. hidden element for the blanks number and button to add new blanks). This makes function interface implementation-dependent.

      Using $prefix param instead we achieve two goals:
      1) reduce the number of arguments (there are quite many of them)
      2) decouple function interface from implementation, allowing adding new form elements in the function without further interface breaks

      The patch is done as preliminary work for MDL-20732, but is useful in itself. It also will be very good to get it in Moodle 2.0 before release to avoid library interface breaks in stable version while main work will be done.

      Attached patch fixes all calls to the repeat_elements existing in Moodle core. It is trivial, so I hope someone could check it in fast.

            moodle.com Moodle HQ
            oa_sychev Oleg Sychev
            Votes:
            0 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:

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