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 %} -
-
- - {{ question['title'] }} - +{% block answer %} +
+
+ {% for n,opt in enumerate(question['options']) %} + + + {{ opt }} + + {% end %}
-
- -
- {{ md(question['text']) }} -
- -
-
- {% for n,opt in enumerate(question['options']) %} - - - {{ opt }} - - {% end %} -
-
-
-
+ +{% end %} \ No newline at end of file diff --git a/templates/question-radio.html b/templates/question-radio.html index d50d9d5..70440bf 100644 --- a/templates/question-radio.html +++ b/templates/question-radio.html @@ -1,28 +1,15 @@ +{% extends "question.html" %} {% autoescape %} -
-
- - {{ question['title'] }} - +{% block answer %} +
+
+ {% for n,opt in enumerate(question['options']) %} + + + {{ md(opt) }} + + {% end %}
- -
- -
- {{ md(question['text']) }} -
- -
-
- {% for n,opt in enumerate(question['options']) %} - - - {{ md(opt) }} - - {% end %} -
-
- -
-
\ No newline at end of file + +{% end %} \ No newline at end of file diff --git a/templates/question-text.html b/templates/question-text.html index b717535..42fd2c2 100644 --- a/templates/question-text.html +++ b/templates/question-text.html @@ -1,21 +1,7 @@ -{% autoescape %} +{% extends "question.html" %} - -
-
- - {{ question['title'] }} - -
- -
- -
- {{ md(question['text']) }} -
- -
- -
-
-
+{% block answer %} +
+ +
+{% end %} \ No newline at end of file diff --git a/templates/question-textarea.html b/templates/question-textarea.html index aa0c4cd..82d9f19 100644 --- a/templates/question-textarea.html +++ b/templates/question-textarea.html @@ -1,19 +1,7 @@ +{% extends "question.html" %} {% autoescape %} - -
-
- - {{ question['title'] }} - -
- -
-
- {{ md(question['text']) }} -
- -
- -
-
+{% block answer %} +
+ +{% end %} \ No newline at end of file -- libgit2 0.21.2