~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 04:48:07 UTC
  • mfrom: (1099.1.243 exercise-ui)
  • Revision ID: grantw@unimelb.edu.au-20090317044807-pozdt54fapazp2sp
Merge lp:~ivle-dev/ivle/exercise-ui.

Lecturers can now add and edit exercises, and worksheets can be written
in RST directly inside IVLE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
import ivle.database
29
29
from ivle.database import Exercise, ExerciseAttempt, ExerciseSave, Worksheet, \
30
30
                          Offering, Subject, Semester, WorksheetExercise
31
 
import ivle.worksheet
 
31
import ivle.worksheet.utils
32
32
import ivle.conf
33
33
import ivle.webapp.tutorial.test
34
 
 
35
34
from ivle.webapp.base.rest import (JSONRESTView, named_operation,
36
35
                                   require_permission)
37
36
from ivle.webapp.errors import NotFound
52
51
            raise NotFound()
53
52
        
54
53
        self.worksheet_exercise = req.store.find(WorksheetExercise,
55
 
            WorksheetExercise.exercise_id == exercise,
 
54
            WorksheetExercise.exercise_id == unicode(exercise),
56
55
            WorksheetExercise.worksheet_id == Worksheet.id,
57
56
            Worksheet.offering_id == Offering.id,
 
57
            Worksheet.identifier == unicode(worksheet),
58
58
            Offering.subject_id == Subject.id,
59
59
            Subject.short_name == subject,
60
60
            Offering.semester_id == Semester.id,
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.get_exercise_status(req.store,
117
 
            req.user, self.worksheet_exercise)
 
116
        completed, attempts = ivle.worksheet.utils.get_exercise_status(
 
117
                req.store, 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.get_exercise_attempt(req.store, user,
 
159
        attempt = ivle.worksheet.utils.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
 
 
215
214
# Note that this is the view of an existing worksheet. Creation is handled
216
215
# by OfferingRESTView (as offerings have worksheets)
217
216
class WorksheetRESTView(JSONRESTView):
243
242
        self.context.assessable = self.convert_bool(assessable)
244
243
        self.context.data = unicode(data)
245
244
        self.context.format = unicode(format)
246
 
        ivle.worksheet.update_exerciselist(self.context)
 
245
        ivle.worksheet.utils.update_exerciselist(self.context)
247
246
        
248
247
        return {"result": "ok"}
249
248
 
283
282
        
284
283
        # This call is added for clarity, as the worksheet is implicitly added.        
285
284
        req.store.add(new_worksheet)
286
 
        
287
 
        ivle.worksheet.update_exerciselist(new_worksheet)
288
 
        
 
285
 
 
286
        ivle.worksheet.utils.update_exerciselist(new_worksheet)
 
287
 
289
288
        return {"result": "ok"}
290
289
 
291
290
    @named_operation('edit')