diff --git a/serve.py b/serve.py index 7e61bef..7d813c3 100755 --- a/serve.py +++ b/serve.py @@ -130,19 +130,9 @@ class LearnHandler(BaseHandler): # ---------------------------------------------------------------------------- # respond to AJAX to get a JSON question class QuestionHandler(BaseHandler): - # @tornado.web.authenticated - # def get(self): - # question = self.application.learn.next_question() - # print('---> question.get') - # print(question) - # if question['type'] == 'checkbox': - # self.render('question-checkbox.html', - # question=question, - # md=md, - # ) - - # else: - # self.write('Error!!!') + @tornado.web.authenticated + def get(self): + self.redirect('/') @tornado.web.authenticated def post(self): @@ -189,12 +179,6 @@ class QuestionHandler(BaseHandler): 'correct': correct, }) - # if question['type'] == 'checkbox': - # self.render('question-checkbox.html', - # question=question, # the dictionary with the question?? - # md=md, # passes function that renders markdown to html - # ) - # ---------------------------------------------------------------------------- def main(): diff --git a/templates/learn.html b/templates/learn.html index 04b1c92..f738bbc 100644 --- a/templates/learn.html +++ b/templates/learn.html @@ -100,7 +100,41 @@ $.fn.extend({ } }); +// function getCookie(name) { +// var r = document.cookie.match("\\b" + name + "=([^;]*)\\b"); +// return r ? r[1] : undefined; +// } + +// jQuery.postJSON = function(url, args, callback) { +// args._xsrf = getCookie("_xsrf"); +// alert(args); +// $.ajax({url: url, data: $.param(args), dataType: "text", type: "POST", +// success: function(response) { +// callback(eval("(" + response + ")")); +// }}); +// } + function getQuestion() { + // var data = $("#question_form").serialize(); + // $.postJSON('/question', data, function(response){ + // $("#question_div").html(response["html"]); + // MathJax.Hub.Queue(["Typeset",MathJax.Hub,"question"]); + + // if (response["correct"]) { + // $('#question_div').animateCSS('pulse'); + // } + // else { + // $('#question_div').animateCSS('shake'); + // } + + // $("input:text").bind("keypress", function (e) { + // if (e.keyCode == 13) { + // e.preventDefault(); + // getQuestion(); + // } + // }); + // }); + $.ajax({ type: "POST", url: "/question", diff --git a/templates/question-checkbox.html b/templates/question-checkbox.html index 5114ce0..b86ce5c 100644 --- a/templates/question-checkbox.html +++ b/templates/question-checkbox.html @@ -1,26 +1,15 @@ +{% extends "question.html" %} {% autoescape %} -