488
488
ctx['worksheets'] = self.context.worksheets
490
490
ctx['mediapath'] = media_url(req, Plugin, 'images/')
493
class ExerciseEditView(XHTMLView):
494
"""View for editing a worksheet."""
497
template = 'templates/exercise_edit.html'
499
def __init__(self, req, exercise):
500
self.context = req.store.find(Exercise,
501
Exercise.id == exercise).one()
503
if self.context is None:
506
def populate(self, req, ctx):
507
self.plugin_styles[Plugin] = ['exercise_admin.css']
508
self.plugin_scripts[Plugin] = ['exercise_admin.js']
510
ctx['exercise'] = self.context
511
#XXX: These should come from somewhere else
513
ctx['var_types'] = (u'file', u'var', u'arg', u'exception')
514
ctx['part_types'] = (u'stdout',u'stderr', u'result',
515
u'exception', u'file', u'code')
517
ctx['test_types'] = ('norm', 'check')
494
519
class Plugin(ViewPlugin, MediaPlugin):
521
# Worksheet View Urls
496
522
('subjects/:subject/+worksheets/+media/*(path)', SubjectMediaView),
497
523
('subjects/:subject/:year/:semester/+worksheets', OfferingView),
498
524
('subjects/:subject/:year/:semester/+worksheets/+new', WorksheetAddView),
499
525
('subjects/:subject/:year/:semester/+worksheets/+edit', WorksheetsEditView),
500
526
('subjects/:subject/:year/:semester/+worksheets/:worksheet', WorksheetView),
501
527
('subjects/:subject/:year/:semester/+worksheets/:worksheet/+edit', WorksheetEditView),
502
530
('api/subjects/:subject/:year/:semester/+worksheets', WorksheetsRESTView),
503
531
('api/subjects/:subject/:year/:semester/+worksheets/:worksheet/*exercise/'
504
532
'+attempts/:username', AttemptsRESTView),
506
534
'+attempts/:username/:date', AttemptRESTView),
507
535
('api/subjects/:subject/:year/:semester/+worksheets/:worksheet', WorksheetRESTView),
508
536
('api/subjects/:subject/:year/:semester/+worksheets/:worksheet/*exercise', ExerciseRESTView),
539
('+exercises/:exercise/+edit', ExerciseEditView),