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

« back to all changes in this revision

Viewing changes to ivle/webapp/tutorial/__init__.py

  • Committer: Matt Giuca
  • Date: 2010-02-24 12:47:31 UTC
  • mto: This revision was merged to the branch mainline in revision 1701.
  • Revision ID: matt.giuca@gmail.com-20100224124731-r4tgywr2djomab4s
worksheet page: If the viewer has permission to edit, the list of exercises in the contents is replaced by a table showing the statistics on each exercise, including the number of students who have attempted and completed the exercise. Fixed up JavaScript so the dynamic change to a green ball still works on this modified view.

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
        ctx['user'] = req.user
92
92
        ctx['config'] = req.config
93
93
 
 
94
        ctx['show_exercise_stats'] = \
 
95
            'edit_worksheets' in self.context.get_permissions(req.user,
 
96
                                                              req.config)
 
97
 
94
98
        generate_worksheet_data(ctx, req, self.context)
95
99
 
96
100
        ctx['worksheetstream'] = add_exercises(ctx['worksheetstream'], ctx, req)
269
273
    tmpl = loader.load(os.path.join(os.path.dirname(__file__),
270
274
        "templates/exercise_fragment.html"))
271
275
    ex_stream = tmpl.generate(curctx)
 
276
    # Store exercise statistics
 
277
    if (worksheet is not None and
 
278
        'edit_worksheets' in worksheet.get_permissions(req.user, req.config)):
 
279
        exercise_stats = ivle.worksheet.utils.get_exercise_statistics(
 
280
            req.store, worksheet_exercise)
 
281
    else:
 
282
        exercise_stats = None
272
283
    return {'name': exercise.name,
273
284
            'complete': curctx['complete_class'],
274
285
            'stream': ex_stream,
275
 
            'exid': exercise.id}
 
286
            'exid': exercise.id,
 
287
            'stats': exercise_stats}
276
288
 
277
289
 
278
290
# The first element is the default format