def render(self, learner):
   action = self.request.params.get('action')
   if learner:
     if action == 'Submit' or action == 'Delete':
       self.html_form = "html/learner.html"
     self.template_values = {
       'learner': learner,                      
       'deleted': action == 'Delete',
     }
   FormHandler.render(self, learner)  
Beispiel #2
0
  def render(self, item):
#    session = sessions.Session(writer="cookie")
#    session["domain"] = self.request.params['domain'] if self.request.params.has_key('domain') else "int"
#    session["type"] = self.request.params['type'] if self.request.params.has_key('type') else 'mc'
#    session["answer"] = self.request.params.has_key('answer')
    user = item if item else User.retrieve(User, self.user.nickname())
    domains = { 'whole': 'Whole Numbers', 'dec': 'Decimals', 'int': 'Integers', 'frac': 'Fractions'}
    syllabusUnits = db.get(user.syllabusUnitKeys)
    syllabusItems = [s.name for s in syllabusUnits]
    self.template_values = {
      'username' : self.user.nickname(),                            
      'domainType' : domains[user.domainType],
      'questionType': "Multiple Choice" if user.questionType == "mc" else "Text",
      'numquestions': user.numquestions,
      'answermode': "Show Answers" if "on" == user.answermode else "Do not show answers",
      'syllabusUnits': syllabusItems,
    }
    FormHandler.render(self, item)
Beispiel #3
0
 def render(self, template):
     action = self.request.params.get("action")
     if template:
         if action == "Submit" or action == "Delete":
             self.html_form = "html/template.html"
         variables = []
         preview = ""
         if action != "Delete":
             for v in Variable.all().ancestor(template):
                 varDomains = {"name": v.name, "type": Domain.internalToExternalType(v.domain.type)}
                 variables.append(varDomains)
             defaultVarDomain = Domain.defaultDomain(Domain.WHOLE_NUMBER)
             preview = template.generateProblemStatement(defaultVarDomain, "text", False)
         self.template_values = {
             "problemName": template.problemName,
             "template": template,
             "variables": variables,
             "deleted": action == "Delete",
             "preview": preview,
         }
     FormHandler.render(self, template)