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

« back to all changes in this revision

Viewing changes to ivle/worksheet/utils.py

Allow hiding of worksheets from students, and hiding of worksheet marks out of 5. Also add column for per-offering worksheet cutoff date, as yet unimplemented.

Show diffs side-by-side

added added

removed removed

Lines of Context:
317
317
    
318
318
    Do not confuse this with a worksheet in the database. This worksheet
319
319
    has extra information for use in the output, such as marks."""
320
 
    def __init__(self, id, name, assessable):
 
320
    def __init__(self, id, name, assessable, published):
321
321
        self.id = id
322
322
        self.name = name
323
323
        self.assessable = assessable
 
324
        self.published = published
324
325
        self.complete_class = ''
325
326
        self.optional_message = ''
326
327
        self.total = 0
331
332
 
332
333
 
333
334
# XXX: This really shouldn't be needed.
334
 
def create_list_of_fake_worksheets_and_stats(store, user, offering):
 
335
def create_list_of_fake_worksheets_and_stats(config, store, user, offering):
335
336
    """Take an offering's real worksheets, converting them into stats.
336
337
 
337
338
    The worksheet listing views expect special fake worksheet objects
345
346
    problems_total = 0
346
347
 
347
348
    # Offering.worksheets is ordered by the worksheets seq_no
348
 
    for worksheet in offering.worksheets:
 
349
    worksheets = offering.worksheets
 
350
 
 
351
    # Unless we can edit worksheets, hide unpublished ones.
 
352
    if 'edit_worksheets' not in offering.get_permissions(user, config):
 
353
        worksheets = worksheets.find(published=True)
 
354
 
 
355
    for worksheet in worksheets:
349
356
        new_worksheet = FakeWorksheetForMarks(
350
 
            worksheet.identifier, worksheet.name, worksheet.assessable)
 
357
            worksheet.identifier, worksheet.name, worksheet.assessable,
 
358
            worksheet.published)
351
359
        if new_worksheet.assessable:
352
360
            # Calculate the user's score for this worksheet
353
361
            mand_done, mand_total, opt_done, opt_total = (