{{extend 'layout.html'}}
..............
..............
..............
{{
total=0
for report in form:
perc=(float(report.marks)/float(report.total))*float(100)
if perc>=100:
grade='A'
elif perc>=79:
grade='B'
elif perc>=69:
grade='C'
elif perc>=59:
grade='D'
elif perc>=39:
grade='E'
elif perc>=19:
grade='U'
}}
{{pass}}
{{
total+=perc
average=int(total/totalNum)
if average>=100:
avGrade='A'
elif average
>=79:
avGrade='B'
elif average
>=69:
avGrade='C'
elif average
>=59:
avGrade='D'
elif average
>=39:
avGrade='E'
elif average
>=19:
avGrade='E'
}}
{{pass}}
<tr>
<td>{{=report.term.term}}</td>
<td>{{=report.subject.subject_name}}</td>
<td>{{=report.marks}}</td>
<td>{{=report.total}}</td>
<td>
{{=perc}}(%)
</td>
<td>{{=grade}}</td>
</td>
<td>{{=report.comments}}</td>
</tr>
{{pass}}
{{pass}}
</table>
</div>
<div class="grades" style="margin-left: 5px;">
<table>
<tr>
<th>AVERAGE</th>
<th>TOTAL/GRADE</th>
<th>CLASS/PS</th>
<th>SCHOOL/PS</th>
</tr>
<tr>
<td>{{=average
}}(%)</td>
<td>{{=avGrade}}</td>
<td>3</td>
<td>21</td>
</tr>
</table>
________________________________________ Kiran Subbaraman http://subbaraman.wordpress.com/about/
I am getting wrong results with my grading system, i think this is more of a syntax problem, i just don't know where I'm mixing up things. My system is supposed to give students grades depending on what percentages they got but the grades do not correspond well with the percentages. I'm getting wrong grades for percentages, e.g 90% is supposed to give me grade 'A' but it is giving me grade 'B', they are all mixed up!!! Can someone assist please?! Thanks.
Here is my code:
{{extend 'layout.html'}}
..............
..............
..............
{{
total=0
for report in form:
perc=(float(report.marks)/float(report.total))*float(100)
if perc>=100:
grade='A'
elif perc>=79:
grade='B'
elif perc>=69:
grade='C'
elif perc>=59:
grade='D'
elif perc>=39:
grade='E'
elif perc>=19:
grade='U'
}}
{{pass}}
{{
total+=
perc
average=int(average/totalNum)
--
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
if perc >= 90:
And I'd also be grateful if someone just simple explained what {{pass}} does in web2py and where do we place it because i find myself placing it in wrong places and at times it just disrupts the balance of the entire code if i don't place it correctly, that'd mean a lot, thanks.
{{if some_condition:}}
This
{{else:}}
That
{{pass}}
Now we are outside the "else" block, so this line will always be displayed.
I want grade 'A' to fall within a range of percentages, 'A' ranges from 80%(being the lowest) to 100%(being the highest), how do i reflect that here to get the system to grade properly??
if perc>=100:
grade='A'
elif perc>=79:
grade='B'
elif perc>=69:
grade='C'
if perc >=100:
grade='A'
elif perc >= 79:
grade='B'
...