~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: 2009-05-19 02:54:08 UTC
  • mfrom: (1258 trunk)
  • mto: This revision was merged to the branch mainline in revision 1322.
  • Revision ID: matt.giuca@gmail.com-20090519025408-19c7cjl7w6ot6frm
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
import genshi
34
34
 
35
 
import ivle.util
36
 
import ivle.conf
37
35
import ivle.database
38
36
from ivle.database import Subject, Offering, Semester, Exercise, \
39
37
                          ExerciseSave, WorksheetExercise
137
135
                ctx['complete_class'] = "semicomplete"
138
136
            else:
139
137
                ctx['complete_class'] = "incomplete"
140
 
            ctx['problems_pct'] = (100 * problems_done) / problems_total
141
 
 
142
 
            # We want to display a students mark out of 5. However, they are
143
 
            # allowed to skip 1 in 5 questions and still get 'full marks'.
144
 
            # Hence we divide by 16, essentially making 16 percent worth
145
 
            # 1 star, and 80 or above worth 5.
146
 
            ctx['max_mark'] = 5
147
 
            ctx['mark'] = min(ctx['problems_pct'] / 16, ctx['max_mark'])
 
138
            # Calculate the final percentage and mark for the subject
 
139
            ctx['problems_pct'], ctx['mark'], ctx['max_mark'] = (
 
140
                ivle.worksheet.utils.calculate_mark(
 
141
                    problems_done, problems_total))
148
142
 
149
143
class WorksheetView(XHTMLView):
150
144
    '''The view of a worksheet with exercises.'''
204
198
        if not self.context:
205
199
            raise NotFound()
206
200
 
207
 
        subjectdir = os.path.join(ivle.conf.subjects_base,
 
201
        subjectdir = os.path.join(req.config['paths']['data'],
 
202
                                  'content/subjects',
208
203
                                  self.context.short_name, 'media')
209
204
        return os.path.join(subjectdir, self.path)
210
205