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


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