Ejemplo n.º 1
0
  def get(self):
    domainType = self.request.get('domain', default_value='whole')
    questionType = self.request.get('type', default_value='mc')
    highlightAnswer = int(self.request.get('answermode', default_value='1'))
    syllabus = self.request.get('syllabus', default_value='BODMAS rule')
    domain = Domain.defaultDomain(Domain.externalToInternalType(domainType))
    syllabusUnits = SyllabusUnit.all().filter("name = ", syllabus)
    knowledgeUnits = [s.knowledgeUnit for s in syllabusUnits]
    modelProblems = ModelProblem.findModelProblemsMatchingKnowledgeUnits(knowledgeUnits) 
    problems = []
    tags = self.request.get_all("tag")
    numquestions = int(self.request.get('numquestions', default_value=3))
    outputFormat = self.request.get('format', default_value='json')
    self.html_form = 'html/quiz.html' if outputFormat == 'html' else 'html/quiz.json'
    
    # At least one tag must match
    while len(problems) < numquestions:
      problem = GenerateQuestionForModelProblems(modelProblems, domain, tags, questionType, highlightAnswer, outputFormat)
      logging.info("Num problems generated = " + str(len(problems)))
      if problem:
        problems.append(problem)

    self.template_values = {
      'problems' : problems,
    }
    FormHandler.get(self)
Ejemplo n.º 2
0
 def fetchChildren(self, parentUnit):
   childList = []
   for child in SyllabusUnit.all().filter('parentUnit', parentUnit).fetch(1000):
     name = child.name + ':' + str(child.key().id()) if child.knowledgeUnit else child.name
     childList.append(name.encode('utf-8'))
     children = self.fetchChildren(child)
     if children:
       childList.append(children)
   return childList
Ejemplo n.º 3
0
  def get(self):
    user = users.get_current_user()
    username = ""
    syllabus = ""
    if user:
      username = user.nickname()
      user = User.retrieve(User, username)
      root = SyllabusUnit.all().filter('name', "CBSE Mathematics 6th").fetch(1)[0]
      syllabus = self.fetchChildren(root)

    self.template_values = {
      'username' : username,                            
      'domainType' : user.domainType if hasattr(user, 'domainType') else "dec",
      'questionType': user.questionType if hasattr(user, 'questionType') else "mc",
      'answermode': user.answermode if hasattr(user, 'answermode') else "No",
      'syllabus': str(syllabus),
    }
    FormHandler.get(self)
Ejemplo n.º 4
0
def initSyllabusInDb(force = False):
  t = SyllabusUnit.all().fetch(1)
  if t and not force:
    return
  # Delete all templates
  for unit in SyllabusUnit.all():
    unit.delete()
    
  math6 = [ {'name': "Natural Numbers and Whole Numbers", 'domainType' : Domain.WHOLE_NUMBER, 'degreeOfDifficulty': 1}, 
                               [ "Face Value and Place Value", 
                                 "Place Value Chart", 
                                    [ {'name': "Indian System", 'knowledgeUnit': 'PlaceValueIndian'},
                                      {'name': "International System", 'knowledgeUnit': 'PlaceValueInternational'},
                                    ],
                                 {'name': "Whole Numbers on the Number Ray", 'knowledgeUnit': 'WholeNumbers'},
                                    [ "Smallest and Largest number",
                                      "Successor",
                                      "Predecessor",
                                      "Order Property",
                                      "Betweenness",
                                    ],
                               ],
            {'name': "Playing with Numbers", 'domainType': Domain.WHOLE_NUMBER },
                               [ {'name': "BODMAS rule", 'knowledgeUnit': "Bodmas"},
                                 {'name': "Factors and Multiples", 'knowledgeUnit': "Factors"},
                                 {'name': "Prime and Composite Numbers", 'knowledgeUnit': "PrimeNumbers"},
                                 {'name': "Tests of Divisibility", 'knowledgeUnit': "DivisibilityTests"},
                                 {'name': "Prime Factorisation", 'knowledgeUnit': "PrimeFactors"},
                                 {'name': "Highest Common Factor", 'knowledgeUnit': "Gcd"},
                                 {'name': "Lowest Common Multiple", 'knowledgeUnit': "Lcm"},                                   
                               ],
            {'name': "Operations on Whole Numbers", 'domainType': Domain.WHOLE_NUMBER },
                               [ "Properties of Addition",
                                 "Properties of Subtraction",
                                 "Properties of Multiplication",
                                 "Properties of Division",
                               ],                                   
            { 'name': "Negative Numbers and Integers", 'domainType': Domain.INTEGER },
                               [ "Ordering",
                                 "Properties of Addition",
                                 "Properties of Subtraction",
                               ],                                   
            { 'name': "Fractions", 'domainType': Domain.FRACTION },
                               [ "Proper, Improper and Mixed",
                                 "Comparison",
                                 "Addition and Subtraction",
                               ],
            { 'name': "Decimal Fractions", 'domainType': Domain.DECIMAL },
                               [ "Place Value",
                                 "Like and Unlike decimal fractions",
                                 "Conversion fraction to decimal, decimal to fraction",
                                 "Addition and Subtraction",
                               ],
            "Algebraic Expressions",
                               [ "Constants and Variables",
                                 "Algebraic operations",
                               ],
            {'name': "Ratio, Proportion and the Unitary Method", 'domainType': Domain.WHOLE_NUMBER, 'degreeOfDifficulty': 1 },
                               [ {'name': "Ratios and fractions", 'knowledgeUnit': "DirectProportion"}, 
                                 {'name': "Proportions", 'knowledgeUnit': "DirectProportion"},
                                 "Continued Proportion",
                                 {'name': "Direct variation and unitary method", 'knowledgeUnit': "DirectProportion"},
                               ],
            "Basic Geometrical Ideas",
                               [ "Point",
                                 "Line",
                                 "Plane",
                                 "Open and Closed Figures",
                                 "Angles",
                                 "Triangles",
                                 "Quadrilaterals",
                                 "Circles, chords and Arcs",
                               ],
            "Two dimensional shapes",
                               [ "Measurement of line segments",
                                 "Measurement of angles",
                                 "Types of angles",
                                 "Properties of points, lines and planes",
                                 "Types of triangles",
                                 "Types of quadrilaterals",
                               ],                                   
            "Three dimensional shapes",
                               [ "Cubes and cuboids",
                                 "Shapes with curved sides",
                                 "Prisms",
                                 "Pyramids",
                                 "Nets of solids",
                               ],
            "Symmetry", 
                               [ "Reflection" ],
            "Constructions",
                               [ "Line segments",
                                 "Angles using a protractor",
                                 "Ruler and Set squares",
                                 "Parallel and Perpendicular lines",
                                 "Circle",
                                 "Ruler and Compass",
                               ],
            {'name': "Perimeter and Area", 'domainType': Domain.DECIMAL },
                               [ "Perimeter",
                                 "Area",
                               ],
            "Data Handling",
                               [ "Tally Marks",
                                 "Pictographs",
                                 "Bar Graph",
                               ],
  ]
  SyllabusUnit.saveSyllabusUnit(None, "CBSE Mathematics 6th", math6)