311
311
return test_results
314
class FakeWorksheetForMarks:
315
"""This class represents a worksheet and a particular students progress
318
Do not confuse this with a worksheet in the database. This worksheet
319
has extra information for use in the output, such as marks."""
320
def __init__(self, id, name, assessable):
323
self.assessable = assessable
324
self.complete_class = ''
325
self.optional_message = ''
329
return ("Worksheet(id=%s, name=%s, assessable=%s)"
330
% (repr(self.id), repr(self.name), repr(self.assessable)))
333
# XXX: This really shouldn't be needed.
334
def create_list_of_fake_worksheets_and_stats(store, user, offering):
335
"""Take an offering's real worksheets, converting them into stats.
337
The worksheet listing views expect special fake worksheet objects
338
that contain counts of exercises, whether they've been completed,
339
that sort of thing. A fake worksheet object is used to contain
340
these values, because nobody has managed to refactor the need out
347
# Offering.worksheets is ordered by the worksheets seq_no
348
for worksheet in offering.worksheets:
349
new_worksheet = FakeWorksheetForMarks(
350
worksheet.identifier, worksheet.name, worksheet.assessable)
351
if new_worksheet.assessable:
352
# Calculate the user's score for this worksheet
353
mand_done, mand_total, opt_done, opt_total = (
354
ivle.worksheet.utils.calculate_score(store, user, worksheet))
356
optional_message = " (excluding optional exercises)"
358
optional_message = ""
359
if mand_done >= mand_total:
360
new_worksheet.complete_class = "complete"
362
new_worksheet.complete_class = "semicomplete"
364
new_worksheet.complete_class = "incomplete"
365
problems_done += mand_done
366
problems_total += mand_total
367
new_worksheet.mand_done = mand_done
368
new_worksheet.total = mand_total
369
new_worksheet.optional_message = optional_message
370
new_worksheets.append(new_worksheet)
372
return new_worksheets, problems_total, problems_done