~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 13:13:21 UTC
  • mfrom: (1689.1.19 worksheet-marks)
  • Revision ID: matt.giuca@gmail.com-20100224131321-eno7xbrqsyukz869
Added worksheet marks reporting UI for lecturers. This includes the ability to view worksheet marks table in the web application and download as a CSV, as well as some basic statistics on exercise completion. Removed the ivle-marks script, as now lecturers can get the same data themselves. Fixes Launchpad bug #520179.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
            WorksheetBreadcrumb)
66
66
from ivle.webapp.tutorial.media import (SubjectMediaFile, SubjectMediaView,
67
67
    subject_to_media)
 
68
from ivle.webapp.tutorial.marks import (WorksheetsMarksView,
 
69
            WorksheetsMarksCSVView)
68
70
 
69
71
 
70
72
class WorksheetView(XHTMLView):
89
91
        ctx['user'] = req.user
90
92
        ctx['config'] = req.config
91
93
 
 
94
        ctx['show_exercise_stats'] = \
 
95
            'edit' in self.context.get_permissions(req.user,
 
96
                                                   req.config)
 
97
 
92
98
        generate_worksheet_data(ctx, req, self.context)
93
99
 
94
100
        ctx['worksheetstream'] = add_exercises(ctx['worksheetstream'], ctx, req)
267
273
    tmpl = loader.load(os.path.join(os.path.dirname(__file__),
268
274
        "templates/exercise_fragment.html"))
269
275
    ex_stream = tmpl.generate(curctx)
 
276
    # Store exercise statistics
 
277
    if (worksheet is not None and
 
278
        'edit' 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
270
283
    return {'name': exercise.name,
271
284
            'complete': curctx['complete_class'],
272
285
            'stream': ex_stream,
273
 
            'exid': exercise.id}
 
286
            'exid': exercise.id,
 
287
            'stats': exercise_stats}
274
288
 
275
289
 
276
290
# The first element is the default format
577
591
 
578
592
    views = [(Offering, ('+worksheets', '+new'), WorksheetAddView),
579
593
             (Offering, ('+worksheets', '+edit'), WorksheetsEditView),
 
594
             (Offering, ('+worksheets', '+marks', '+index'),
 
595
              WorksheetsMarksView),
 
596
             (Offering, ('+worksheets', '+marks', 'marks.csv'),
 
597
              WorksheetsMarksCSVView),
580
598
             (Worksheet, '+index', WorksheetView),
581
599
             (Worksheet, '+edit', WorksheetEditView),
582
600
             (ApplicationRoot, ('+exercises', '+index'), ExercisesView),