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

« back to all changes in this revision

Viewing changes to ivle/worksheet/utils.py

  • 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:
211
211
    # allowed to skip 1 in 5 questions and still get 'full marks'.
212
212
    # Hence we divide by 16, essentially making 16 percent worth
213
213
    # 1 star, and 80 or above worth 5.
214
 
    percent_int = (100 * mand_done) / mand_total
 
214
    if mand_total > 0:
 
215
        percent_int = (100 * mand_done) // mand_total
 
216
    else:
 
217
        # Avoid Div0, just give everyone 0 marks if there are none available
 
218
        percent_int = 0
215
219
    # percent / 16, rounded down, with a maximum mark of 5
216
220
    max_mark = 5
217
221
    mark = min(percent_int // 16, max_mark)