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

« back to all changes in this revision

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

  • Committer: Nick Chadwick
  • Date: 2009-03-09 00:45:58 UTC
  • mfrom: (1156 trunk)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090309004558-xvvj990b9h9y23bu
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
from ivle.worksheet.rst import rst as rstfunc
48
48
from ivle.webapp.tutorial.service import AttemptsRESTView, AttemptRESTView, \
49
49
            WorksheetExerciseRESTView, WorksheetRESTView, WorksheetsRESTView
 
50
 
50
51
from ivle.webapp.tutorial.exercise_service import ExercisesRESTView, \
51
52
                                                  ExerciseRESTView
52
53
 
78
79
        """Find the given offering by subject, year and semester."""
79
80
        self.context = req.store.find(Offering,
80
81
            Offering.subject_id == Subject.id,
81
 
            Subject.code == subject,
 
82
            Subject.short_name == subject,
82
83
            Offering.semester_id == Semester.id,
83
84
            Semester.year == year,
84
85
            Semester.semester == semester).one()
92
93
        self.plugin_styles[Plugin] = ['tutorial.css']
93
94
 
94
95
        ctx['subject'] = self.context.subject
95
 
        ctx['year'] = self.context.semester.year
96
 
        ctx['semester'] = self.context.semester.semester
 
96
        ctx['offering'] = self.context
 
97
        ctx['user'] = req.user
97
98
 
98
99
        # As we go, calculate the total score for this subject
99
100
        # (Assessable worksheets only, mandatory problems only)
155
156
        self.context = req.store.find(DBWorksheet,
156
157
            DBWorksheet.offering_id == Offering.id,
157
158
            Offering.subject_id == Subject.id,
158
 
            Subject.code == subject,
 
159
            Subject.short_name == subject,
159
160
            Offering.semester_id == Semester.id,
160
161
            Semester.year == year,
161
162
            Semester.semester == semester,
180
181
        ctx['year'] = self.year
181
182
 
182
183
        ctx['worksheetstream'] = genshi.Stream(list(genshi.XML(self.context.get_xml())))
 
184
        ctx['user'] = req.user
183
185
 
184
186
        generate_worksheet_data(ctx, req, self.context)
185
187
 
194
196
    permission = 'view'
195
197
 
196
198
    def __init__(self, req, subject, path):
197
 
        self.context = req.store.find(Subject, code=subject).one()
 
199
        self.context = req.store.find(Subject, short_name=subject).one()
198
200
        self.path = os.path.normpath(path)
199
201
 
200
202
    def _make_filename(self, req):
203
205
            raise NotFound()
204
206
 
205
207
        subjectdir = os.path.join(ivle.conf.subjects_base,
206
 
                                  self.context.code, 'media')
 
208
                                  self.context.short_name, 'media')
207
209
        return os.path.join(subjectdir, self.path)
208
210
 
209
211
def get_worksheets(subjectfile):
401
403
            Semester.year == year,
402
404
            Semester.semester == semester,
403
405
            Offering.subject_id == Subject.id,
404
 
            Subject.code == subject
 
406
            Subject.short_name == subject
405
407
        ).one()
406
408
        
407
409
        if self.context is None:
437
439
            Semester.year == year,
438
440
            Semester.semester == semester,
439
441
            Offering.subject_id == Subject.id,
440
 
            Subject.code == subject
 
442
            Subject.short_name == subject
441
443
        ).one()
442
444
        
443
445
        self.subject = subject
470
472
            Semester.year == year,
471
473
            Semester.semester == semester,
472
474
            Offering.subject_id == Subject.id,
473
 
            Subject.code == subject
 
475
            Subject.short_name == subject
474
476
        ).one()
475
477
        
476
478
        self.subject = subject
585
587
                '+attempts/:username/:date', AttemptRESTView),
586
588
        ('api/subjects/:subject/:year/:semester/+worksheets/:worksheet', WorksheetRESTView),
587
589
        ('api/subjects/:subject/:year/:semester/+worksheets/:worksheet/*exercise', WorksheetExerciseRESTView),
588
 
        
 
590
 
589
591
        # Exercise View Urls
590
592
        ('+exercises', ExercisesView),
591
593
        ('+exercises/:exercise/+edit', ExerciseEditView),