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

XMLWordPrintable

#### Details

• New Feature
• Status: Closed
• Minor
• Resolution: Fixed
• Future Dev
• MOODLE_37_STABLE
• MDL-64414-master
• Hide
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
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

#### 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. 1.PNG
172 kB
2. 2.PNG
178 kB
3. Documentation in the Wiki.docx
18 kB

#### People

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

#### Dates

Created:
Updated:
Resolved:
20/May/19

#### Time Tracking

Estimated:
0m
Remaining:
0m
Logged:
1h