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

Make it possible to use AND, OR in if-conditions for grade calculations

    XMLWordPrintable

Details

    • MOODLE_37_STABLE
    • MDL-64414-master
    • Hide
      1. Login as Admin
      2. Create a course.
      3. Enrol a Teacher and at least three students in the course.
      4. Login as a Teacher.
      5. Access to the "Gradebook setup" clicking over the Grades option in the Navigation menu and selection the "Setup" tab.
      6. Add four grade items with the following "Item name"s: "item1", "item2", "item3", "item4". Make sure the "Grade type" is set to "Value".
      7. Access to the "Edit calculation" form for the "Course total".
      8. Set the ID numbers for the items to "item1", "item2", "item3" and "item4".
      9. Enter in the Calculation text area one of the formulas you'll find at the end.
      10. Go to "Grader report" and "Turn editing on".
      11. Enter manually the following values for the item1, item2, item3 and item4:
        1. user1: 0 for all the items
        2. user2: 5 for all the items
        3. user3: 6 for all the items
      12. Save grades.
      13. Check whether the values of the formulas are 1 (true) or 0 (false) because of the defined conditions (for each formula is explained which is the expected result).
      14. Repeat the steps 9-13 for all the formulas

       

      Formulas:

      if-clause
      Formula: =if([[item1]]>5,1,0)
      Expected values: user1 = 0, user2 = 0, user3 = 1

      if+and(1-2)-clause
      Formula: =if(and([[item1]]>5,[[item2]]>5),1,0)
      Expected values: user1 = 0, user2 = 0, user3 = 1

      if+and(1-4)-clause
      Formula: =if(and([[item1]]>5,[[item2]]>5,[[item3]]>5,[[item4]]>5),1,0)
      Expected values: user1 = 0, user2 = 0, user3 = 1

      if+and(sum(1-2)),sum(3-4))-clause
      Formula: =if(and(sum([[item1]],[[item2]])>5,sum([[item3]],[[item4]])>5,1,0)
      Expected values: user1 = 0, user2 = 1, user3 = 1

      if+or(1-2)-clause
      Formula: =if(or([[item1]]>5,[[item2]]>5),1,2)
      Expected values: user1 = 2, user2 = 2, user3 = 1

      if+or(1-4)-clause
      Formula: =if(or([[item1]]>5,[[item2]]>5,[[item3]]>5,[[item4]]>5),1,0)
      Expected values: user1 = 0, user2 = 0, user3 = 1

      if+or(sum(1-2)),sum(3-4))-clause
      Formula: =if(or(sum([[item1]],[[item2]])>5,sum([[item3]],[[item4]])>5),1,2)
      Expected values: user1 = 2, user2 = 1, user3 = 1

      if+and(or(1-2),or(3-4))-clause
      Formula: =if(and(or([[item1]]>5,[[item2]]>5),or([[item3]]>5,[[item4]]>5)),1,2)
      Expected values: user1 = 2, user2 = 2, user3 = 1

      Show
      Login as Admin Create a course. Enrol a Teacher and at least three students in the course. Login as a Teacher. Access to the "Gradebook setup" clicking over the Grades option in the Navigation menu and selection the "Setup" tab. Add four grade items with the following "Item name"s: "item1", "item2", "item3", "item4". Make sure the "Grade type" is set to "Value". Access to the "Edit calculation" form for the "Course total". Set the ID numbers for the items to "item1", "item2", "item3" and "item4". Enter in the Calculation text area one of the formulas you'll find at the end. Go to "Grader report" and "Turn editing on". Enter manually the following values for the item1, item2, item3 and item4: user1: 0 for all the items user2: 5 for all the items user3: 6 for all the items Save grades. Check whether the values of the formulas are 1 (true) or 0 (false) because of the defined conditions (for each formula is explained which is the expected result). Repeat the steps 9-13 for all the formulas   Formulas : if-clause Formula: =if([ [item1] ]>5,1,0) Expected values: user1 = 0, user2 = 0, user3 = 1 if+and(1-2)-clause Formula: =if(and([ [item1] ]>5,[ [item2] ]>5),1,0) Expected values: user1 = 0, user2 = 0, user3 = 1 if+and(1-4)-clause Formula: =if(and([ [item1] ]>5,[ [item2] ]>5,[ [item3] ]>5,[ [item4] ]>5),1,0) Expected values: user1 = 0, user2 = 0, user3 = 1 if+and(sum(1-2)),sum(3-4))-clause Formula: =if(and(sum([ [item1] ],[ [item2] ])>5,sum([ [item3] ],[ [item4] ])>5,1,0) Expected values: user1 = 0, user2 = 1, user3 = 1 if+or(1-2)-clause Formula: =if(or([ [item1] ]>5,[ [item2] ]>5),1,2) Expected values: user1 = 2, user2 = 2, user3 = 1 if+or(1-4)-clause Formula: =if(or([ [item1] ]>5,[ [item2] ]>5,[ [item3] ]>5,[ [item4] ]>5),1,0) Expected values: user1 = 0, user2 = 0, user3 = 1 if+or(sum(1-2)),sum(3-4))-clause Formula: =if(or(sum([ [item1] ],[ [item2] ])>5,sum([ [item3] ],[ [item4] ])>5),1,2) Expected values: user1 = 2, user2 = 1, user3 = 1 if+and(or(1-2),or(3-4))-clause Formula: =if(and(or([ [item1] ]>5,[ [item2] ]>5),or([ [item3] ]>5,[ [item4] ]>5)),1,2) Expected values: user1 = 2, user2 = 2, user3 = 1

    Description

      With MDL-14274 it is now possible to add if conditions to grade calculations like so:
      IF(item1>50, 99, 0)

      This new feature aims to also include the possibility to use AND, OR for IF clauses.

      e.g.:
      IF (OR(item1==23, item2<45), 99, 0)
      IF (AND(item1==23, item2<45), 99, 0)

      Attachments

        1. Documentation in the Wiki.docx
          18 kB
        2. 2.PNG
          2.PNG
          178 kB
        3. 1.PNG
          1.PNG
          172 kB

        Issue Links

          Activity

            People

              stefanerlachner Stefan Erlachner
              stefanerlachner Stefan Erlachner
              Victor Déniz Falcón Victor Déniz Falcón
              Sara Arjona (@sarjona) Sara Arjona (@sarjona)
              Janelle Barcega Janelle Barcega
              Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
              Votes:
              0 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                20/May/19

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour
                  1h