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

« back to all changes in this revision

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

  • Committer: Nick Chadwick
  • Date: 2009-02-24 03:32:59 UTC
  • mto: (1099.1.227 exercise-ui)
  • mto: This revision was merged to the branch mainline in revision 1162.
  • Revision ID: chadnickbok@gmail.com-20090224033259-m518nuqp6w9f23ax
Added a new page to display exercises. This will then be modified to
actually edit exercises.

Show diffs side-by-side

added added

removed removed

Lines of Context:
488
488
        ctx['worksheets'] = self.context.worksheets
489
489
        
490
490
        ctx['mediapath'] = media_url(req, Plugin, 'images/')
491
 
        
492
 
 
 
491
 
 
492
 
 
493
class ExerciseEditView(XHTMLView):
 
494
    """View for editing a worksheet."""
 
495
    
 
496
    permission = 'edit'
 
497
    template = 'templates/exercise_edit.html'
 
498
    
 
499
    def __init__(self, req, exercise):
 
500
        self.context = req.store.find(Exercise, 
 
501
            Exercise.id == exercise).one()
 
502
 
 
503
        if self.context is None:
 
504
            raise NotFound()
 
505
    
 
506
    def populate(self, req, ctx):
 
507
        self.plugin_styles[Plugin] = ['exercise_admin.css']
 
508
        self.plugin_scripts[Plugin] = ['exercise_admin.js']
 
509
        
 
510
        ctx['exercise'] = self.context
 
511
        #XXX: These should come from somewhere else
 
512
 
 
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')
 
516
        
 
517
        ctx['test_types'] = ('norm', 'check')
493
518
 
494
519
class Plugin(ViewPlugin, MediaPlugin):
495
520
    urls = [
 
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),
 
528
        
 
529
        # Worksheet Api Urls
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),
 
537
        
 
538
        # Exercise View Urls
 
539
        ('+exercises/:exercise/+edit', ExerciseEditView),
 
540
        
 
541
        # Exercise Api Urls
509
542
    ]
510
543
 
511
544
    media = 'media'