I think you need to give a bit more context.  What are your model 
definitions for db.student_class and db.marks?  Does each student have 
multiple rows in the marks table?

On Thursday, 30 November 2017 09:12:14 UTC, mostwanted wrote:
>
> I'm at the brink of pulling my hairs out!!!
> Can please please someone out there help me, in my results management 
> system i want to add up the students averages and give the their class 
> positions and level positions according to how their averages add up. 
> Number 1 being the one with position 1 and so on but i dont know how to 
> achieve this!
>
> The paln i came up with was to select the students of the class, add up 
> their averages individually, store them in a list. Then in the view sort 
> them up starting with the highest, select the average that a specific 
> selected student got and its index+1 the use that index as the student's 
> position. This was my perfect plan but its falling apart in code!!
>
> *CONTROLLER*: 
> select the averages of students of a particular specified class and store 
> them in the averages list
> def genrate_report():    
>     averages=[]
>     marks=db(db.student_class.class_name=='5A').select(db.marks.ALL)
>     summed=0
>     for fo in marks:
>         summed +=fo.average
>         averages.append(summed)    
>     return locals()
>
> *VIEW:* the averages are sorted in the list they are in, in a reverse 
> order and the index of the student's total average is selected and used as 
> the student position
> {{
>             {{
>             percent=sorted(averages, key=int, reverse=True)
>             position=percent.index(totalav)+1
>             }}
>             {{pass}}
>
>             <td>{{=percent}}</td>
>             <td>{{=grade}}</td>
>
> Thank you
>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to