~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to bin/ivle-marks

  • Committer: Matt Giuca
  • Date: 2009-04-24 13:55:05 UTC
  • mto: This revision was merged to the branch mainline in revision 1196.
  • Revision ID: matt.giuca@gmail.com-20090424135505-14as031os0kdi0zd
ivle-marks, ivle.worksheet.utils: Fixed Divide-by-zero exception if there are
    0 mandatory exercises in a worksheet - gives everyone 0 marks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
        # We simply ignore optional exercises here
76
76
        mand_done, mand_total, _, _ = (
77
77
            ivle.worksheet.utils.calculate_score(store, user, worksheet))
78
 
        worksheet_pcts.append(float(mand_done) / mand_total)
 
78
        if mand_total > 0:
 
79
            worksheet_pcts.append(float(mand_done) / mand_total)
 
80
        else:
 
81
            # Avoid Div0, just give everyone 0 marks if there are none
 
82
            worksheet_pcts.append(0.0)
79
83
        problems_done += mand_done
80
84
        problems_total += mand_total
81
85
    percent, mark, _ = (