Example #1
0
    def post(self):
        # figure out if we pressed the reset button
        if self.get_argument("action", None) == "reset":
            models.reset_quizzes()
            self.render("quizzes.html", quizzes=models.get_quizzes())

        # get the words corresponding to a tag and randomize their order
        words = [result.word_id for result in models.get_words_with_tag(self.get_argument("tag"))]

        # Check to see if there are any words
        # TODO(hammer): Should probably tell the user what's up here
        if len(words) == 0:
            self.render("quizzes.html", quizzes=models.get_quizzes())

        # store the new quiz
        models.put_quiz(self.get_argument("tag"), self.get_argument("front"), int(time.time()), words)

        # Re-render the quizzes page
        self.render("quizzes.html", quizzes=models.get_quizzes())
Example #2
0
 def get(self):
     self.render("quizzes.html", quizzes=models.get_quizzes())