Browse Source

DIV-631: If a user does not answer a pre-qual question, they are provided with a link to the step that contains the unanswered question

pull/160/head
Benard Ebinu 8 years ago
parent
commit
0fea875b8d
4 changed files with 71 additions and 8 deletions
  1. +9
    -4
      edivorce/apps/core/templates/incomplete.html
  2. +35
    -0
      edivorce/apps/core/utils/question_step_mapping.py
  3. +23
    -1
      edivorce/apps/core/utils/step_completeness.py
  4. +4
    -3
      edivorce/apps/core/views/main.py

+ 9
- 4
edivorce/apps/core/templates/incomplete.html View File

@ -26,11 +26,16 @@
of forms</a> that may be required for a Joint Divorce can also be found on the Family Law
in B.C. website.
</p>
{% if debug %}
<hr>
<p>Unanswered: {{ missed_questions }}</p>
{% endif %}
<p>Below are the unanswered questions. Please click on the link to go back and answer the question:</p>
<ul>
{% for missed_question in missed_questions %}
<li>
<a href="{{ missed_question.step_url }}">{{ missed_question.title }}</a>
</li>
{% endfor %}
</ul>
</div>


+ 35
- 0
edivorce/apps/core/utils/question_step_mapping.py View File

@ -1,3 +1,38 @@
"""
Mapping between steps in the pre-qualification stage and the questions on each
step. Useful for showing a human readable link and message when a question is not
answered. The user can click the link to take them back to the step containing the
unanswered question.
"""
pre_qual_step_question_mapping = {
'01': {
'married_marriage_like'
},
'02': {
'lived_in_bc',
'lived_in_bc_at_least_year'
},
'03': {
'separation_date',
'try_reconcile_after_separated',
'reconciliation_period'
},
'04': {
'children_of_marriage',
'number_children_under_19',
'number_children_over_19',
'children_financial_support'
},
'05': {
'original_marriage_certificate',
'provide_certificate_later',
'marriage_certificate_in_english'
},
'06': {
'divorce_reason',
}
}
"""
Mapping between questions and steps
Usage: For each step title, list all questions_keys belong to that step


+ 23
- 1
edivorce/apps/core/utils/step_completeness.py View File

@ -1,5 +1,7 @@
from django.core.urlresolvers import reverse
from edivorce.apps.core.models import Question
from edivorce.apps.core.utils.question_step_mapping import question_step_mapping
from edivorce.apps.core.utils.question_step_mapping import question_step_mapping, pre_qual_step_question_mapping
def evaluate_numeric_condition(target, reveal_response):
@ -77,6 +79,26 @@ def is_complete(step, lst):
return complete, missing_responses
def get_formatted_incomplete_list(missed_question_keys):
"""
Returns a list of dicts that contain the following information for the question
that was not answered. Each dict contains the name of the question, as stored in
the database, and the url of the page where the question is found.
:param missed_question_keys:
:return: list of dicts.
"""
missed_questions = []
for missed_question in Question.objects.filter(key__in=missed_question_keys):
for step, questions in pre_qual_step_question_mapping.items():
if missed_question.key in questions:
missed_questions.append({
'title': missed_question.name,
'step_url': reverse('prequalification', kwargs={'step': step})
})
return missed_questions
def __condition_met(reveal_response, target, lst):
# check whether using a numeric condition
numeric_condition_met = evaluate_numeric_condition(target["value"], reveal_response)


+ 4
- 3
edivorce/apps/core/views/main.py View File

@ -7,7 +7,7 @@ from django.template import RequestContext
from ..decorators import bceid_required, intercept
from ..utils.question_step_mapping import list_of_registries
from ..utils.step_completeness import get_step_status, is_complete
from ..utils.step_completeness import get_step_status, is_complete, get_formatted_incomplete_list
from ..utils.template_step_order import template_step_order
from ..utils.user_response import get_responses_from_db, copy_session_to_db, \
get_responses_from_db_grouped_by_steps, get_responses_from_session, \
@ -67,11 +67,12 @@ def incomplete(request):
This page is shown if the user misses any pre-qualification questions
"""
prequal_responses = get_responses_from_session_grouped_by_steps(request)['prequalification']
_, missed_questions = is_complete('prequalification', prequal_responses)
_, missed_question_keys = is_complete('prequalification', prequal_responses)
missed_questions = get_formatted_incomplete_list(missed_question_keys)
responses_dict = get_responses_from_session(request)
responses_dict.append(('debug', settings.DEBUG, ))
responses_dict.append(('missed_questions', str(missed_questions), ))
responses_dict.append(('missed_questions', missed_questions, ))
return render(request, 'incomplete.html', context=responses_dict)


Loading…
Cancel
Save