aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYingtong Li <runassudo@yingtongli.me>2017-03-28 22:14:33 +1100
committerYingtong Li <runassudo@yingtongli.me>2017-03-28 22:14:33 +1100
commitc14ec43fbf3b6e7edcd3fe8bac8edb71be2f1cc5 (patch)
tree83d6e6ab87d4b5d22947913f5635afae1b9f3c51
parent13308b3f9a9ec85f92b0a2f2a7d93eb4579ea308 (diff)
Add answer form configuration for type questions
-rw-r--r--pblive/data.py10
-rw-r--r--pblive/templates/question_type.html9
-rw-r--r--pblive/templates/question_type_admin.html2
3 files changed, 17 insertions, 4 deletions
diff --git a/pblive/data.py b/pblive/data.py
index dc1e449..8d1f2d8 100644
--- a/pblive/data.py
+++ b/pblive/data.py
@@ -98,6 +98,16 @@ class RandomQuestion(Question):
class TypeQuestion(Question):
template = 'question_type.html'
template_admin = 'question_type_admin.html'
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+ self.answer_form = kwargs.get('answer_form', '$1')
+
+ def load_dict(self, obj):
+ super().load_dict(obj)
+
+ self.answer_form = obj.get('answer_form', self.answer_form)
class SpeedQuestion(MCQQuestion):
template = 'question_speed.html'
diff --git a/pblive/templates/question_type.html b/pblive/templates/question_type.html
index 1e4497d..ac42050 100644
--- a/pblive/templates/question_type.html
+++ b/pblive/templates/question_type.html
@@ -19,9 +19,12 @@
{% extends 'question.html' %}
{% block base %}
- <div class="ui input">
- <input type="text" id="answer" name="answer" value="{{ user.answers[question_num] }}">
- </div>
+ {% set answerinput %}
+ <div class="ui input">
+ <input type="text" id="answer" name="answer" value="{{ user.answers[question_num] }}">
+ </div>
+ {% endset %}
+ <div>{{ session.questions[question_num].answer_form.replace('$1', answerinput)|safe }}</div>
<script>
var submitAnswerTimer = 0;
diff --git a/pblive/templates/question_type_admin.html b/pblive/templates/question_type_admin.html
index 6788f71..ca1c3c3 100644
--- a/pblive/templates/question_type_admin.html
+++ b/pblive/templates/question_type_admin.html
@@ -23,7 +23,7 @@
<ul class="ui list">
{% for answer, users in data.unique_answers_for_question(session, question_num).items() %}
<li style="line-height: 32px;">
- {{ answer }}:
+ {{ session.questions[question_num].answer_form.replace('$1', answer) }}:
{% for user in users %}
<button class="ui button" style="background-color: {{ user.colour[1] }}; width: 32px; height: 32px; padding: 0 0;">{{ user.colour[0] }}</button>
{% endfor %}
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.