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

« back to all changes in this revision

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

  • Committer: Matt Giuca
  • Date: 2010-02-25 06:10:59 UTC
  • mfrom: (1721 trunk)
  • mto: This revision was merged to the branch mainline in revision 1731.
  • Revision ID: matt.giuca@gmail.com-20100225061059-qkt9qcvsvjyepdp8
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
            'edit' in self.context.get_permissions(req.user,
96
96
                                                   req.config)
97
97
 
98
 
        generate_worksheet_data(ctx, req, self.context)
 
98
        generate_worksheet_data(ctx, req, self._loader, self.context)
99
99
 
100
100
        ctx['worksheetstream'] = add_exercises(ctx['worksheetstream'], ctx, req)
101
101
 
154
154
 
155
155
# This function runs through the worksheet, to get data on the exercises to
156
156
# build a Table of Contents, as well as fill in details in ctx
157
 
def generate_worksheet_data(ctx, req, worksheet):
 
157
def generate_worksheet_data(ctx, req, loader, worksheet):
158
158
    """Runs through the worksheetstream, generating the exericises"""
159
159
    ctx['exercises'] = []
160
160
    ctx['exerciselist'] = []
170
170
                        optional = attr[1] == 'true'
171
171
                # Each item in toc is of type (name, complete, stream)
172
172
                if src != "":
173
 
                    ctx['exercises'].append(present_exercise(req, src, worksheet))
 
173
                    ctx['exercises'].append(
 
174
                        present_exercise(req, loader, src, worksheet))
174
175
                    ctx['exerciselist'].append((src, optional))
175
176
            elif data[0] == 'worksheet':
176
177
                ctx['worksheetname'] = 'bob'
201
202
 
202
203
    return data.strip()
203
204
 
204
 
def present_exercise(req, identifier, worksheet=None):
 
205
def present_exercise(req, loader, identifier, worksheet=None):
205
206
    """Render an HTML representation of an exercise.
206
207
 
207
208
    identifier: The exercise identifier (URL name).
269
270
 
270
271
    #Save the exercise details to the Table of Contents
271
272
 
272
 
    loader = genshi.template.TemplateLoader(".", auto_reload=True)
273
273
    tmpl = loader.load(os.path.join(os.path.dirname(__file__),
274
274
        "templates/exercise_fragment.html"))
275
275
    ex_stream = tmpl.generate(curctx)
481
481
        ctx['mediapath'] = media_url(req, Plugin, 'images/')
482
482
        ctx['exercise'] = self.context
483
483
        ctx['exercise_fragment'] = present_exercise(
484
 
            req, self.context.id)['stream']
 
484
            req, self._loader, self.context.id)['stream']
485
485
        ctx['ExerciseEditView'] = ExerciseEditView
486
486
        ctx['ExerciseDeleteView'] = ExerciseDeleteView
487
487