~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: 2010-02-24 09:51:04 UTC
  • Revision ID: grantw@unimelb.edu.au-20100224095104-nl3ndy0cysz2ioad
Add support for "really deep" (more than two segment) views.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from ivle.database import Exercise, ExerciseAttempt, ExerciseSave, Worksheet, \
29
29
                          Offering, Subject, Semester, User, WorksheetExercise
30
30
import ivle.worksheet.utils
31
 
from ivle.webapp.base.rest import (JSONRESTView, write_operation,
 
31
from ivle.webapp.base.rest import (JSONRESTView, named_operation,
32
32
                                   require_permission)
33
33
from ivle.webapp.errors import NotFound
34
34
 
56
56
    @require_permission('edit')
57
57
    def PUT(self, req, data):
58
58
        """ Tests the given submission """
59
 
        # Trim off any trailing whitespace (can cause syntax errors in python)
60
 
        # While technically this is a user error, it causes a lot of confusion 
61
 
        # for student since it's "invisible".
62
 
        code = data['code'].rstrip()
63
 
 
64
59
        test_results = ivle.worksheet.utils.test_exercise_submission(
65
60
            req.config, req.user, self.context.worksheet_exercise.exercise,
66
 
            code)
 
61
            data['code'])
67
62
 
68
63
        attempt = ivle.database.ExerciseAttempt(user=req.user,
69
64
            worksheet_exercise = self.context.worksheet_exercise,
70
65
            date = datetime.datetime.now(),
71
66
            complete = test_results['passed'],
72
 
            text = unicode(code)
 
67
            text = unicode(data['code'])
73
68
        )
74
69
 
75
70
        req.store.add(attempt)
96
91
class WorksheetExerciseRESTView(JSONRESTView):
97
92
    '''REST view of a worksheet exercise.'''
98
93
 
99
 
    @write_operation('view')
 
94
    @named_operation('view')
100
95
    def save(self, req, text):
101
96
        # Find the appropriate WorksheetExercise to save to. If its not found,
102
97
        # the user is submitting against a non-existant worksheet/exercise
123
118
class WorksheetsRESTView(JSONRESTView):
124
119
    """View used to update and create Worksheets."""
125
120
 
126
 
    @write_operation('edit_worksheets')
 
121
    @named_operation('edit_worksheets')
127
122
    def move_up(self, req, worksheetid):
128
123
        """Takes a list of worksheet-seq_no pairs and updates their 
129
124
        corresponding Worksheet objects to match."""
144
139
        
145
140
        return {'result': 'ok'}
146
141
 
147
 
    @write_operation('edit_worksheets')
 
142
    @named_operation('edit_worksheets')
148
143
    def move_down(self, req, worksheetid):
149
144
        """Takes a list of worksheet-seq_no pairs and updates their 
150
145
        corresponding Worksheet objects to match."""