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

« back to all changes in this revision

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

  • Committer: Nick Chadwick
  • Date: 2009-03-08 01:26:24 UTC
  • mto: (1099.1.227 exercise-ui)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090308012624-yitpjd28xzt14fsj
Exercise-ui is now able to create an entire exercise.

Show diffs side-by-side

added added

removed removed

Lines of Context:
180
180
        req.store.add(new_case)
181
181
        
182
182
        return {'result': 'ok'}
 
183
    
 
184
    @named_operation(u'edit')
 
185
    def edit_testcase(self, req, suiteid, testid, passmsg, failmsg, default):
 
186
        
 
187
        suite = req.store.find(TestSuite,
 
188
            TestSuite.suiteid == int(suiteid),
 
189
            TestSuite.exercise_id == self.context.id).one()
 
190
        if suite is None:
 
191
            raise NotFound('testsuite')
 
192
        
 
193
        test_case = req.store.find(TestCase,
 
194
            TestCase.suiteid == suite.suiteid,
 
195
            TestCase.testid == int(testid)).one()
 
196
        if test_case is None:
 
197
            raise NotFound('testcase')
 
198
        
 
199
        test_case.passmsg = unicode(passmsg)
 
200
        test_case.failmsg = unicode(failmsg)
 
201
        test_case.default = unicode(default)
 
202
        
 
203
        return {'result': 'ok'}
 
204
    
 
205
    @named_operation(u'edit')
 
206
    def edit_testpart(self, req, suiteid, testid, partid, part_type, test_type, 
 
207
                      data, filename):
 
208
    
 
209
        suite = req.store.find(TestSuite,
 
210
            TestSuite.suiteid == int(suiteid),
 
211
            TestSuite.exercise_id == self.context.id).one()
 
212
        if suite is None:
 
213
            raise NotFound('testsuite')
 
214
        
 
215
        test_case = req.store.find(TestCase,
 
216
            TestCase.suiteid == suite.suiteid,
 
217
            TestCase.testid == int(testid)).one()
 
218
        if test_case is None:
 
219
            raise NotFound('testcase')
 
220
        
 
221
        test_part = req.store.find(TestCasePart,
 
222
            TestCasePart.testid == test_case.testid,
 
223
            TestCasePart.partid == int(partid)).one()
 
224
        if test_part is None:
 
225
            raise NotFound('testcasepart')
 
226
        
 
227
        test_part.part_type = unicode(part_type)
 
228
        test_part.test_type = unicode(test_type)
 
229
        test_part.data = unicode(data)
 
230
        test_part.filename = unicode(filename)
 
231
        
 
232
        return {'result': 'ok'}
 
233
    
 
234
    @named_operation(u'edit')
 
235
    def add_testpart(self, req, suiteid, testid, part_type, test_type, 
 
236
                      data, filename):
 
237
    
 
238
        suite = req.store.find(TestSuite,
 
239
            TestSuite.suiteid == int(suiteid),
 
240
            TestSuite.exercise_id == self.context.id).one()
 
241
        if suite is None:
 
242
            raise NotFound('testsuite')
 
243
        
 
244
        test_case = req.store.find(TestCase,
 
245
            TestCase.suiteid == suite.suiteid,
 
246
            TestCase.testid == int(testid)).one()
 
247
        if test_case is None:
 
248
            raise NotFound('testcase')
 
249
        
 
250
        test_part = TestCasePart()
 
251
        test_part.part_type = unicode(part_type)
 
252
        test_part.test_type = unicode(test_type)
 
253
        test_part.data = unicode(data)
 
254
        test_part.filename = unicode(filename)
 
255
        
 
256
        test_case.parts.add(test_part)
 
257
        
 
258
        return {'result': 'ok'}