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

« back to all changes in this revision

Viewing changes to ivle/worksheet/utils.py

  • Committer: Matt Giuca
  • Date: 2010-02-24 13:04:11 UTC
  • mfrom: (1700 trunk)
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: matt.giuca@gmail.com-20100224130411-s7acw3afckv8rudh
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
331
331
    
332
332
    Do not confuse this with a worksheet in the database. This worksheet
333
333
    has extra information for use in the output, such as marks."""
334
 
    def __init__(self, id, name, assessable):
 
334
    def __init__(self, id, name, assessable, published):
335
335
        self.id = id
336
336
        self.name = name
337
337
        self.assessable = assessable
 
338
        self.published = published
338
339
        self.complete_class = ''
339
340
        self.optional_message = ''
340
341
        self.total = 0
345
346
 
346
347
 
347
348
# XXX: This really shouldn't be needed.
348
 
def create_list_of_fake_worksheets_and_stats(store, user, offering):
 
349
def create_list_of_fake_worksheets_and_stats(config, store, user, offering):
349
350
    """Take an offering's real worksheets, converting them into stats.
350
351
 
351
352
    The worksheet listing views expect special fake worksheet objects
359
360
    problems_total = 0
360
361
 
361
362
    # Offering.worksheets is ordered by the worksheets seq_no
362
 
    for worksheet in offering.worksheets:
 
363
    worksheets = offering.worksheets
 
364
 
 
365
    # Unless we can edit worksheets, hide unpublished ones.
 
366
    if 'edit_worksheets' not in offering.get_permissions(user, config):
 
367
        worksheets = worksheets.find(published=True)
 
368
 
 
369
    for worksheet in worksheets:
363
370
        new_worksheet = FakeWorksheetForMarks(
364
 
            worksheet.identifier, worksheet.name, worksheet.assessable)
 
371
            worksheet.identifier, worksheet.name, worksheet.assessable,
 
372
            worksheet.published)
365
373
        if new_worksheet.assessable:
366
374
            # Calculate the user's score for this worksheet
367
375
            mand_done, mand_total, opt_done, opt_total = (