On Monday, November 27, 2017 at 4:41:20 PM UTC+2, Pierre wrote:
>
> here:
>
> http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#sum--avg--min--max-and-len
>
> and don't be too severe with your students...........
>

I am having an issue, in the process of calculating the total sum of 
*averages* i also add them up to the the database's *totalAverage* field so 
that i retain this information to monitor student performance, the problem 
now is it adds all the values in *averages* except the last value in the 
the list, for an example if i have the values *1,2,3,4,5,6  *which have to 
add up to 21 its gonna end its addition with the value 5 giving me a sum of 
15 leaving out the value of 6 which would've given me a total of 21. How 
can i get it to add them up all as it adds them the *totalAverage* field?

Here is my code:

def calcPerc(form):    
    summed=db.marks.average.sum()
    totalav=db().select(summed).first()[summed]
    form.vars.totalAverage=totalav
    if totalav>=80 and totalav<100:
        avGrade='A'
        form.vars.averageGrade=avGrade
    elif totalav<=79 and totalav>=70:
        avGrade='B'
        form.vars.averageGrade=avGrade
    elif totalav<=69 and totalav>=60:
        avGrade='C'
        form.vars.averageGrade=avGrade

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to