31
31
from xml.dom import minidom
34
from storm.locals import Store
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
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,
49
WorksheetExerciseRESTView, WorksheetRESTView, WorksheetsRESTView)
54
50
from ivle.webapp.tutorial.exercise_service import ExercisesRESTView, \
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,
58
60
"""This class represents a worksheet and a particular students progress
493
495
ctx['mediapath'] = media_url(req, Plugin, 'images/')
496
def offering_to_worksheet(offering, worksheet_name):
497
return Store.of(offering).find(
499
DBWorksheet.offering == offering,
500
DBWorksheet.identifier == worksheet_name
504
def root_to_exercise(root, exercise_name):
505
return root.store.find(
507
Exercise.id == exercise_name
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),
499
forward_routes = (root_to_exercise, offering_to_worksheet,
500
worksheet_to_worksheetexercise, worksheetexercise_to_exerciseattempts,
501
exerciseattempts_to_attempt)
503
reverse_routes = (exercise_url, worksheet_url, worksheetexercise_url,
504
exerciseattempts_url, exerciseattempt_url)
520
506
views = [(Offering, ('+worksheets', '+index'), OfferingView),
521
507
(Offering, ('+worksheets', '+new'), WorksheetAddView),