From 4a666a877c867d8ecc386be05064ba006d392b4e Mon Sep 17 00:00:00 2001 From: Charles Connell Date: Tue, 4 Mar 2014 16:02:43 -0500 Subject: [PATCH] More little fixes --- karmaworld/apps/quizzes/views.py | 7 ++-- karmaworld/assets/css/quiz.css | 8 +++- karmaworld/assets/js/quiz.js | 24 +++++++++++ karmaworld/settings/common.py | 1 + karmaworld/templates/quizzes/quiz.html | 55 ++++++++++++++++---------- 5 files changed, 71 insertions(+), 24 deletions(-) diff --git a/karmaworld/apps/quizzes/views.py b/karmaworld/apps/quizzes/views.py index c67205d..80c98b5 100644 --- a/karmaworld/apps/quizzes/views.py +++ b/karmaworld/apps/quizzes/views.py @@ -36,6 +36,7 @@ class QuizView(DetailView): reverse=True) kwargs['questions'] = result_list + kwargs['quiz'] = self.object return super(QuizView, self).get_context_data(**kwargs) @@ -120,8 +121,8 @@ def quiz_answer(request): except Exception, e: return HttpResponseBadRequest(json.dumps({'status': 'fail', - 'message': e.message, - 'exception': e.__class__.__name__}), - mimetype="application/json") + 'message': e.message, + 'exception': e.__class__.__name__}), + mimetype="application/json") return HttpResponse(json.dumps({'correct': correct}), mimetype="application/json") \ No newline at end of file diff --git a/karmaworld/assets/css/quiz.css b/karmaworld/assets/css/quiz.css index 4b51e87..25938bd 100644 --- a/karmaworld/assets/css/quiz.css +++ b/karmaworld/assets/css/quiz.css @@ -98,4 +98,10 @@ .wrong-answer { background-color: #ffb4b4; -} \ No newline at end of file +} + +div.question ul +{ + list-style-type: none; +} + diff --git a/karmaworld/assets/js/quiz.js b/karmaworld/assets/js/quiz.js index f78f4dc..7ff9884 100644 --- a/karmaworld/assets/js/quiz.js +++ b/karmaworld/assets/js/quiz.js @@ -19,10 +19,22 @@ function prevQuestion() { } } +function updateCorrectCount() { + var count = 0; + for (var i = 0; i < num_quiz_questions; i++) { + if (correct_questions[i]) { + count += 1 + } + } + $('#num-correct').html(count); +} + function checkAnswerCallback(data, textStatus, jqXHR) { var question = $('div[data-question-index="' + current_question_index + '"]'); var question_text = question.find('p.question-text'); if (data.correct == true) { + correct_questions[current_question_index] = true; + updateCorrectCount(); question_text.removeClass('wrong-answer'); question_text.removeClass('correct-answer'); question_text.addClass('correct-answer-flash'); @@ -73,8 +85,20 @@ function checkAnswer() { } $(function () { + // show the first question showQuestion(); + + // set up handlers $('button.check-answer').click(checkAnswer); $('button.prev-question').click(prevQuestion); $('button.next-question').click(nextQuestion); + $('input.multiple-choice-choice').click(checkAnswer); + $('input.true-false-choice').click(checkAnswer); + + // initialize record of correct answers + correct_questions = new Array(num_quiz_questions); + for (var i = 0; i < num_quiz_questions; i++) { + correct_questions[i] = false; + } + }); \ No newline at end of file diff --git a/karmaworld/settings/common.py b/karmaworld/settings/common.py index ccc410c..c3299f7 100644 --- a/karmaworld/settings/common.py +++ b/karmaworld/settings/common.py @@ -29,6 +29,7 @@ ALLOWED_HOSTS = [ 'beta.karmanotes.org', 'www.karmanotes.org', 'karmanotes.org', + 'ec2-184-73-42-39.compute-1.amazonaws.com', ] ########## END SECURITY CONFIGURATION diff --git a/karmaworld/templates/quizzes/quiz.html b/karmaworld/templates/quizzes/quiz.html index 4b2ac84..3ac6e8a 100644 --- a/karmaworld/templates/quizzes/quiz.html +++ b/karmaworld/templates/quizzes/quiz.html @@ -24,6 +24,13 @@ {% block content %}
+
{{ quiz.name }} @@ -40,11 +47,11 @@
-
- 3 +
+ 0
- 14 + {{ questions|length }}
@@ -81,34 +88,42 @@

{{ question.question_text }}

    {% for choice in question.choices.all %} -
  • -
  • +
  • {% endfor %}
{% endif %} {% if 'TrueFalseQuestion' in item.0 %}

{{ question.text }}

-
  • -
  • -
  • -
  • +
      +
    • +
    • +
    {% endif %} {% if 'FlashCardQuestion' in item.0 %}

    {{ question.definition_side }}

    {% endif %} -- 2.25.1