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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-03-17 03:43:52 UTC
  • Revision ID: grantw@unimelb.edu.au-20090317034352-tiv0h96wmx39fwh4
Expose jQuery in our URL space.

Adds the concept of external media files, which are static files that we
pull in from third-party dependencies and serve under /+media/+external.

A new config option (media/externals/jquery) has been added to specify
where to find jquery.js - it defaults to /usr/share/javascript/jquery,
which is both a generally sane location and also the Debian/Ubuntu one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import datetime
24
24
import genshi
25
25
 
 
26
import ivle.util
26
27
import ivle.console
27
28
import ivle.database
28
29
from ivle.database import Exercise, ExerciseAttempt, ExerciseSave, Worksheet, \
29
30
                          Offering, Subject, Semester, WorksheetExercise
30
 
import ivle.worksheet.utils
 
31
import ivle.worksheet
 
32
import ivle.conf
31
33
import ivle.webapp.tutorial.test
 
34
 
32
35
from ivle.webapp.base.rest import (JSONRESTView, named_operation,
33
36
                                   require_permission)
34
37
from ivle.webapp.errors import NotFound
49
52
            raise NotFound()
50
53
        
51
54
        self.worksheet_exercise = req.store.find(WorksheetExercise,
52
 
            WorksheetExercise.exercise_id == unicode(exercise),
 
55
            WorksheetExercise.exercise_id == exercise,
53
56
            WorksheetExercise.worksheet_id == Worksheet.id,
54
57
            Worksheet.offering_id == Offering.id,
55
 
            Worksheet.identifier == unicode(worksheet),
56
58
            Offering.subject_id == Subject.id,
57
59
            Subject.short_name == subject,
58
60
            Offering.semester_id == Semester.id,
84
86
            raise NotFound()
85
87
 
86
88
        # Start a console to run the tests on
87
 
        jail_path = os.path.join(req.config['paths']['jails']['mounts'],
88
 
                                 req.user.login)
 
89
        jail_path = os.path.join(ivle.conf.jail_base, req.user.login)
89
90
        working_dir = os.path.join("/home", req.user.login)
90
 
        cons = ivle.console.Console(req.config, req.user.unixid, jail_path,
91
 
                                    working_dir)
 
91
        cons = ivle.console.Console(req.user.unixid, jail_path, working_dir)
92
92
 
93
93
        # Parse the file into a exercise object using the test suite
94
94
        exercise_obj = ivle.webapp.tutorial.test.parse_exercise_file(
113
113
        # Query the DB to get an updated score on whether or not this problem
114
114
        # has EVER been completed (may be different from "passed", if it has
115
115
        # been completed before), and the total number of attempts.
116
 
        completed, attempts = ivle.worksheet.utils.get_exercise_status(
117
 
                req.store, req.user, self.worksheet_exercise)
 
116
        completed, attempts = ivle.worksheet.get_exercise_status(req.store,
 
117
            req.user, self.worksheet_exercise)
118
118
        test_results["completed"] = completed
119
119
        test_results["attempts"] = attempts
120
120
 
156
156
            Semester.year == year,
157
157
            Semester.semester == semester).one()
158
158
            
159
 
        attempt = ivle.worksheet.utils.get_exercise_attempt(req.store, user,
 
159
        attempt = ivle.worksheet.get_exercise_attempt(req.store, user,
160
160
                        worksheet_exercise, as_of=date,
161
161
                        allow_inactive=HISTORY_ALLOW_INACTIVE) 
162
162
 
211
211
        return {"result": "ok"}
212
212
 
213
213
 
 
214
 
214
215
# Note that this is the view of an existing worksheet. Creation is handled
215
216
# by OfferingRESTView (as offerings have worksheets)
216
217
class WorksheetRESTView(JSONRESTView):
242
243
        self.context.assessable = self.convert_bool(assessable)
243
244
        self.context.data = unicode(data)
244
245
        self.context.format = unicode(format)
245
 
        ivle.worksheet.utils.update_exerciselist(self.context)
 
246
        ivle.worksheet.update_exerciselist(self.context)
246
247
        
247
248
        return {"result": "ok"}
248
249
 
282
283
        
283
284
        # This call is added for clarity, as the worksheet is implicitly added.        
284
285
        req.store.add(new_worksheet)
285
 
 
286
 
        ivle.worksheet.utils.update_exerciselist(new_worksheet)
287
 
 
 
286
        
 
287
        ivle.worksheet.update_exerciselist(new_worksheet)
 
288
        
288
289
        return {"result": "ok"}
289
290
 
290
291
    @named_operation('edit')