def get(self): subcategories = [(1, 'Algebra'), (2, 'Trigonometry'), (3, 'Geometry')] for subcat in subcategories: sc = Subcategory() sc.category = 1 sc.subcategory = subcat[0] sc.name = subcat[1] sc.put() subcategories = [(1, 'Mechanics (Statics)'), (2, 'Mechanics (Dynamics)'), (3, 'Strength of Materials')] for subcat in subcategories: sc = Subcategory() sc.category = 2 sc.subcategory = subcat[0] sc.name = subcat[1] sc.put() subcategories = [(1, 'DC Circuits'), (2, 'AC Circuits'), (3, 'Electromagnetics')] for subcat in subcategories: sc = Subcategory() sc.category = 3 sc.subcategory = subcat[0] sc.name = subcat[1] sc.put() for category in CATEGORIES: for subcat in getsubcategories(category[0]): for i in range(100): deferred.defer(makeQuestion, category[0], subcat[0], category[1], i, _queue='test')
def post(self): category = int(self.request.get('category')) noall = self.request.get('noall') if noall: allflag = False else: allflag = True subcategories = getsubcategories(category) path = os.path.join(os.path.dirname(__file__), 'templates/quizzer/subcategoryoptions.html') self.response.out.write(template.render(path, dict(subcategories=subcategories, allflag=allflag)))
def post(self): category = self.request.get('category') subcategory = self.request.get('subcategory') cursor = self.request.get('cursor') prevcursors = self.request.get('prevcursors') filterval = self.request.get('filterval') quizzer = users.get_current_user() if prevcursors: prevcursors = prevcursors.split(',') else: prevcursors = [] questions = QuestionQuizzerStats.all() questions.filter("quizzer =", quizzer) if filterval == 'all': pass elif filterval == 'answered': questions.filter("answered =", True) elif filterval == 'unanswered': questions.filter("answered =", False) elif filterval == 'correct': questions.filter("answeredcorrectly =", True) elif filterval == 'wrong': questions.filter("answeredcorrectly =", False) questions.filter("answered =", True) if category != '0': questions.filter('category =', int(category)) if subcategory != '0': questions.filter('subcategory =', int(subcategory)) questions.order('-questiondatetime') if cursor: questions.with_cursor(cursor) prevcursors.append(cursor) qlist = [] qtypedict = dict(QUESTIONTYPES) questionslist = questions.fetch(25) for q in questionslist: d = {} d['key'] = q.parent().key() #if q.questiontype == 1: # d['questiontype'] = 'Numerical Answer' #elif q.questiontype == 2: # d['questiontype'] = 'Text Answer' d['questiontype'] = qtypedict[q.questiontype] if len(q.parent().question) > 40: d['question'] = q.parent().question[:40] + '...' else: d['question'] = q.parent().question d['category'] = dict(CATEGORIES)[q.category] subcategories = getsubcategories(q.category) d['subcategory'] = dict(subcategories)[q.subcategory] if q.timesanswered > 0: d['answered'] = True else: d['answered'] = False qlist.append(d) disablenext = False if len(questionslist) < 25: disablenext = True cursor = questions.cursor() disableprevious = False if not prevcursors: disableprevious = True path = os.path.join(os.path.dirname(__file__), 'templates/quizzer/list.html') self.response.out.write(template.render(path, dict(questions=qlist, cursor=cursor, disablenext=disablenext, disableprevious=disableprevious, prevcursors=','.join(prevcursors))))