IF statement in gradebook formula

IF statement in gradebook formula

by Sandra Frigeri -
Number of replies: 5

Hi,

I need your help.

I Have a course that use this logical for final evaluation:

- it has 3 categories of evaluation

- 2 are mandatory (GA, GB), if the students obtain 70 in sum of them, the student was approved

- else, they need to do 1 more evaluation (GC)

them we have 2 formulas:

finalevaluation = GA + GB (if finalevaluation >= 70, the student has approved)

finalevaluation = (2*(GA + GB) + GC) / 3, for other cases

How can I specified these in grade calculated formula.

thanks.

In reply to Sandra Frigeri

Re: IF statement in gradebook formula

by Marty Soupcoff -

See here. Itamar has written out some workaround examples for others. You'll have to massage it a little for your needs.

Happy Moodle Logooodling!

In reply to Sandra Frigeri

Re: IF statement in gradebook formula

by Bob Puffer -

the key is to use the MAX and MIN functions

In reply to Bob Puffer

Re: IF statement in gradebook formula

by Sandra Frigeri -

Thanks Bob, but I don't know how?

Could you give me a sample with my needs?

We have 2 formulas for finalevaluation and diferente weights in each formula:

finalevaluation = GA + GB (if finalevaluation >= 70, the student has approved)

finalevaluation = (2*(GA + GB) + GC) / 3, for other cases

please help me.

How can I use MIN and MAX functions to express this structure?

Thanks!

In reply to Sandra Frigeri

Re: IF statement in gradebook formula

by Bob Puffer -

Sorry for being so late to reply, I lost this thread on a cold boot.

First off you can't have finalevaluation be two different types of grades, 'value' ((2*(GA + GB) + GC) / 3) and 'scale' (approved).  You definitely will have problems if you call two grades exactly the same thing.  Plus your logic is circular, in other words the value of 'finalevaluation' relies on 'finalevaluation' -- not gonna work on any system.

  1. Let's assume 'Finalevaluation' is your grade for the course and you want it to show 'Approved' or 'Not approved'.  Approved means the student either:
    • got 70 or greater as a sum of GA and GB
    • completed GA, GB and GC
  2. create a separate grade item (GCcalc) that will hold the points calculation. The calculation will be ((2*(GA + GB) + GC)/(2+MIN(GC,1)).  This item will be hidden from the students. If GC is zero you'll be dividing by 2, if not by 3.  This calculation works for either scenario.
  3. Your conditions for GC appearing should be:
    • GA must have a grade
    • GB must have a grade
    • GCcalc must be less than 70
  4. Because its a scale, your calculation for your final grade must result in zero or 1 (not approved or approved). With my assumptions the only instance when this should result in 'not approved' is if GCcalc is less than 70 and GC has not been completed. That causes us to need another intermediate grade item (FINALcalc) which can also be hidden.  The calculation for FINALcalc is MIN(GC+MAX(GA+GB-69,0),1).  Explained:
    • If GA+GB-69 is greater than zero then adding it to GC will produce 1 or more.  MIN(GC+MAX(GA+GB-69,0),1) will result in 1
    • if GA+GB-69 is less than or equal to zero then that portion resolves to zero, added to GC.  
      • If GC is zero than MIN(GC+MAX(GA+GB-69,0),1) = zero and you know they've not gotten better than 69 on GA+GB and not done GC.
      • if GC is greater than zero then MIN(GC+MAX(GA+GB-69,0),1) will resolve to 1