Beispiel #1
0
 def get(self, scenario_id):
     """Show the scenario question to the user."""
     state = LearnerState(self.session)
     scenario = state.annotate_scenario(scenario_id)
     is_completed = state.is_completed(scenario_id)
     context = dict(s=scenario,
                    state=state.as_string(),
                    previous=self.previous(),
                    next=self.next(),
                    show_prevnext=is_completed)
     jt = self.jinja_environment().get_template('scenario.djt')
     self.response.write(jt.render(context))
Beispiel #2
0
    def get(self, scenario_id):
        state = LearnerState(self.session)
        answer_id = state.last_answer_id(scenario_id) or "--none--"
        answer = Answer.get_by_key_name(answer_id)

        if answer is None:
            self.redirect("/%s/question" % scenario_id)
            return

        if state.is_completed(scenario_id):
            link_next = "/%s/disc1" % scenario_id
        else:
            link_next = "/%s/question" % scenario_id

        context = dict(next=self.next(),
                       previous=self.previous(),
                       state=state.as_string(),
                       show_prevnext=False,
                       correct=state.is_completed(scenario_id),
                       response=answer.response,
                       link_next=link_next)

        jt = self.jinja_environment().get_template('response.djt')
        self.response.write(jt.render(context))