~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:44:39 UTC
  • mto: This revision was merged to the branch mainline in revision 1196.
  • Revision ID: matt.giuca@gmail.com-20090424134439-pwgr5gjluocs7l84
ivle.worksheet.utils: Added calculate_mark, which is from the duplicated code
    in both bin/ivle-marks and ivle.webapp.tutorial.OfferingView.populate.
    This calculates a user's final mark for a subject.
ivle-marks, ivle.webapp.tutorial: Call ivle.worksheet.utils.calculate_mark
    instead of manually calculating (avoid code duplication).

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
        worksheet_pcts.append(float(mand_done) / mand_total)
79
79
        problems_done += mand_done
80
80
        problems_total += mand_total
81
 
    problems_pct = float(problems_done) / problems_total
82
 
    problems_pct_int = (100 * problems_done) / problems_total
83
 
    # XXX Marks calculation (should be abstracted out of here!)
84
 
    # percent / 16, rounded down, with a maximum mark of 5
85
 
    max_mark = 5
86
 
    mark = min(problems_pct_int / 16, max_mark)
87
 
    return worksheet_pcts + [problems_pct, mark]
 
81
    percent, mark, _ = (
 
82
        ivle.worksheet.utils.calculate_mark(problems_done, problems_total))
 
83
    return worksheet_pcts + [float(percent)/100, mark]
88
84
 
89
85
def writeuser(worksheets, user, csvfile):
90
86
    userdata = get_userdata(user)