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

« back to all changes in this revision

Viewing changes to www/apps/tutorial/__init__.py

  • Committer: chadnickbok
  • Date: 2009-02-03 03:53:54 UTC
  • Revision ID: svn-v4:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:1193
Fixed a few small issues with the way the Worksheet menus were
being displayed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
208
208
    # (Assessable worksheets only, mandatory problems only)
209
209
    problems_done = 0
210
210
    problems_total = 0
211
 
    for worksheet_from_xml in ctx['worksheets']:
212
 
        worksheet = ivle.database.Worksheet.get_by_name(req.store,
213
 
            subject, worksheet_from_xml.id)
 
211
    ctx['worksheetz'] = []
 
212
    for worksheet in ctx['worksheets']:
 
213
        stored_worksheet = ivle.database.Worksheet.get_by_name(req.store,
 
214
            subject, worksheet.id)
214
215
        # If worksheet is not in database yet, we'll simply not display
215
216
        # data about it yet (it should be added as soon as anyone visits
216
217
        # the worksheet itself).
217
 
        if worksheet is not None:
 
218
        if stored_worksheet is not None:
218
219
            # If the assessable status of this worksheet has changed,
219
220
            # update the DB
220
221
            # (Note: This fails the try block if the worksheet is not yet
221
222
            # in the DB, which is fine. The author should visit the
222
223
            # worksheet page to get it into the DB).
223
 
            if worksheet.assessable != worksheet_from_xml.assessable:
 
224
            if worksheet.assessable != stored_worksheet.assessable:
224
225
                # XXX If statement to avoid unnecessary database writes.
225
226
                # Is this necessary, or will Storm check for us?
226
 
                worksheet.assessable = worksheet_from_xml.assessable
 
227
                stored_worksheet.assessable = worksheet.assessable
227
228
                req.store.commit()
228
229
            if worksheet.assessable:
229
230
                # Calculate the user's score for this worksheet
230
231
                mand_done, mand_total, opt_done, opt_total = (
231
232
                    ivle.worksheet.calculate_score(req.store, req.user,
232
 
                        worksheet))
 
233
                        stored_worksheet))
233
234
                if opt_total > 0:
234
235
                    optional_message = " (excluding optional exercises)"
235
236
                else:
246
247
                worksheet.total = mand_total
247
248
                worksheet.optional_message = optional_message
248
249
 
 
250
 
249
251
    ctx['problems_total'] = problems_total
250
252
    ctx['problems_done'] = problems_done
251
253
    if problems_total > 0: