Skip to content

Commit

Permalink
Display choice and input answers better
Browse files Browse the repository at this point in the history
  • Loading branch information
colmjude committed May 8, 2024
1 parent eed7501 commit bf22f7a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
7 changes: 6 additions & 1 deletion application/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ def global_variables_context_processor():


def register_filters(app):
from application.filters import map_to_tag_class_filter, slugify_filter
from application.filters import (
choice_to_list_filter,
map_to_tag_class_filter,
slugify_filter,
)

app.add_template_filter(choice_to_list_filter, "choice_to_list")
app.add_template_filter(slugify_filter, "slugify")
app.add_template_filter(map_to_tag_class_filter, "map_to_tag_class")

Expand Down
4 changes: 4 additions & 0 deletions application/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ def map_to_tag_class_filter(s):
if s in stage_to_class.keys():
return stage_to_class[s]
return "govuk-tag--blue"


def choice_to_list_filter(s):
return s.split(";")
15 changes: 14 additions & 1 deletion application/templates/questions/set.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,20 @@ <h3 class="govuk-heading-s">{{ question.format(consideration.name) }}</h3>
{% elif question.question_type.value == "choose-one-from-list" %}
<p class="govuk-body">{% if answer %}{{ answer.answer.choice }}{% endif %}</p>
{% else %}
<p class="govuk-body">{% if answer %}{{ answer.answer }}{% endif %}</p>
<p class="govuk-body">{% if answer %}
{% if answer.answer.text -%}
{{ answer.answer.text }}
{% elif answer.answer.choice %}
{% set choices = answer.answer.choice|choice_to_list %}
<ul class="govuk-list govuk-list--bullet">
{%- for choice in choices %}
<li>{{ choice }}</li>
{% endfor -%}
</ul>
{%- else -%}
{{ answer.answer }}
{%- endif %}
{% endif %}</p>
{% endif %}
{%- endif -%}

Expand Down

0 comments on commit bf22f7a

Please sign in to comment.