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

XMLWordPrintable

#### Details

• Type: New Feature
• Status: Closed
• Priority: Minor
• Resolution: Fixed
• Affects Version/s: Future Dev
• Fix Version/s:
• Component/s:
• Labels:
• Testing Instructions:
Hide
2. Create a course.
3. Enrol a Teacher and at least three students in the course.
6. Add four grade items with the following "Item name"s: "item1", "item2", "item3", "item4". Make sure the "Grade type" is set to "Value".
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
• Fixed Branches:
MOODLE_37_STABLE
• Pull from Repository:
• Pull Master Branch:
MDL-64414-master
• Pull Master Diff URL:

#### 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)

#### People

Assignee: Stefan Erlachner
Reporter: Stefan Erlachner
Peer reviewer:
Víctor Déniz Falcón
Integrator:
Sara Arjona (@sarjona)
Tester:
Janelle Barcega
Participants:
Component watchers:
Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
0 Vote for this issue
Watchers:
12 Start watching this issue

#### Dates

Created:
Updated:
Resolved:
Fix Release Date:
20/May/19

#### Time Tracking

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