195
195
return mand_done, mand_total, opt_done, opt_total
197
def calculate_mark(mand_done, mand_total):
198
"""Calculate a subject mark, given the result of all worksheets.
199
@param mand_done: The total number of mandatory exercises completed by
200
some student, across all worksheets.
201
@param mand_total: The total number of mandatory exercises across all
202
worksheets in the offering.
203
@return: (percent, mark, mark_total)
204
percent: The percentage of exercises the student has completed, as an
205
integer between 0 and 100 inclusive.
206
mark: The mark the student has received, based on the percentage.
207
mark_total: The total number of marks available (currently hard-coded
210
# We want to display a students mark out of 5. However, they are
211
# allowed to skip 1 in 5 questions and still get 'full marks'.
212
# Hence we divide by 16, essentially making 16 percent worth
213
# 1 star, and 80 or above worth 5.
214
percent_int = (100 * mand_done) / mand_total
215
# percent / 16, rounded down, with a maximum mark of 5
217
mark = min(percent_int // 16, max_mark)
218
return (percent_int, mark, max_mark)
197
220
def update_exerciselist(worksheet):
198
221
"""Runs through the worksheetstream, generating the appropriate
199
222
WorksheetExercises, and de-activating the old ones."""