Merge pull request #36 from daniboy/dropdown_question_type

Added dropdown (<select>) question type.
EmailTemplateFixes
Denis Krienbühl 2014-11-10 09:03:45 +01:00
commit 0e10ceca54
2 changed files with 14 additions and 2 deletions

View File

@ -2,7 +2,7 @@ from questionnaire import *
from django.utils.translation import ugettext as _, ungettext
from json import dumps
@question_proc('choice', 'choice-freeform')
@question_proc('choice', 'choice-freeform', 'dropdown')
def question_choice(request, question):
choices = []
jstriggers = []
@ -31,7 +31,7 @@ def question_choice(request, question):
'jstriggers': jstriggers,
}
@answer_proc('choice', 'choice-freeform')
@answer_proc('choice', 'choice-freeform', 'dropdown')
def process_choice(question, answer):
opt = answer['ANSWER'] or ''
if not opt:
@ -48,6 +48,7 @@ def process_choice(question, answer):
return dumps([opt])
add_type('choice', 'Choice [radio]')
add_type('choice-freeform', 'Choice with a freeform option [radio]')
add_type('dropdown', 'Dropdown choice [select]')
@question_proc('choice-multiple', 'choice-multiple-freeform')

View File

@ -0,0 +1,11 @@
{% load i18n %}
<div class="clearfix">
<div class="input">
<select id="{{ question.number }}" name="question_{{ question.number }}" onChange="valchanged('{{ question.number }}', this.value)">
<option value="">{% if question.extra %}{{question.extra}}{% else %}--{% endif %}</option>
{% for sel, choice in qdict.choices %}
<option value="{{ choice.value }}"{% if sel %} selected{% endif %}>{{ choice.text }}</option>
{% endfor %}
</select>
</div>
</div>