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

« back to all changes in this revision

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

  • Committer: William Grant
  • Date: 2009-07-05 03:49:31 UTC
  • mto: (1294.4.2 ui-the-third)
  • mto: This revision was merged to the branch mainline in revision 1353.
  • Revision ID: grantw@unimelb.edu.au-20090705034931-e41r97axkoxeitw6
Move i.w.tutorial traversal stuff into i.w.tutorial.traversal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
from xml.dom import minidom
32
32
 
33
33
import genshi
34
 
from storm.locals import Store
35
34
 
36
35
import ivle.database
37
36
from ivle.database import Subject, Offering, Semester, Exercise, \
43
42
from ivle.webapp.base.xhtml import XHTMLView
44
43
from ivle.webapp.base.plugins import ViewPlugin, MediaPlugin
45
44
from ivle.webapp.media import media_url#, BaseMediaFileView
46
 
from ivle.webapp.errors import NotFound, Forbidden
 
45
from ivle.webapp.errors import NotFound
47
46
from ivle.worksheet.rst import rst as rstfunc
 
47
 
48
48
from ivle.webapp.tutorial.service import (AttemptsRESTView, AttemptRESTView,
49
 
            WorksheetExerciseRESTView, WorksheetRESTView, WorksheetsRESTView,
50
 
            ExerciseAttempts, worksheet_to_worksheet_exercise,
51
 
            worksheet_exercise_to_user_attempts, exerciseattempts_to_attempt,
52
 
            )
53
 
 
 
49
            WorksheetExerciseRESTView, WorksheetRESTView, WorksheetsRESTView)
54
50
from ivle.webapp.tutorial.exercise_service import ExercisesRESTView, \
55
51
                                                  ExerciseRESTView
 
52
from ivle.webapp.tutorial.traversal import (root_to_exercise, exercise_url,
 
53
            offering_to_worksheet, worksheet_url,
 
54
            worksheet_to_worksheetexercise, worksheetexercise_url,
 
55
            ExerciseAttempts, worksheetexercise_to_exerciseattempts,
 
56
            exerciseattempts_url, exerciseattempts_to_attempt,
 
57
            exerciseattempt_url)
56
58
 
57
59
class Worksheet:
58
60
    """This class represents a worksheet and a particular students progress
493
495
        ctx['mediapath'] = media_url(req, Plugin, 'images/')
494
496
 
495
497
 
496
 
def offering_to_worksheet(offering, worksheet_name):
497
 
    return Store.of(offering).find(
498
 
        DBWorksheet,
499
 
        DBWorksheet.offering == offering,
500
 
        DBWorksheet.identifier == worksheet_name
501
 
        ).one()
502
 
 
503
 
 
504
 
def root_to_exercise(root, exercise_name):
505
 
    return root.store.find(
506
 
        Exercise,
507
 
        Exercise.id == exercise_name
508
 
        ).one()
509
 
 
510
 
 
511
498
class Plugin(ViewPlugin, MediaPlugin):
512
 
    forward_routes = [(Offering, '+worksheets', offering_to_worksheet, 1),
513
 
                      (DBWorksheet, None, worksheet_to_worksheet_exercise, 1),
514
 
                      (WorksheetExercise, '+attempts',
515
 
                       worksheet_exercise_to_user_attempts, 1),
516
 
                      (ExerciseAttempts, None, exerciseattempts_to_attempt, 1),
517
 
                      (ApplicationRoot, '+exercises', root_to_exercise, 1),
518
 
                      ]
 
499
    forward_routes = (root_to_exercise, offering_to_worksheet,
 
500
        worksheet_to_worksheetexercise, worksheetexercise_to_exerciseattempts,
 
501
        exerciseattempts_to_attempt)
 
502
 
 
503
    reverse_routes = (exercise_url, worksheet_url, worksheetexercise_url,
 
504
        exerciseattempts_url, exerciseattempt_url)
519
505
 
520
506
    views = [(Offering, ('+worksheets', '+index'), OfferingView),
521
507
             (Offering, ('+worksheets', '+new'), WorksheetAddView),