-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dynamic labels for DMA form flow results #64
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,8 +113,8 @@ card GetAssessment, then: CheckEnd do | |
|
||
log("Starting assessment @config.items.assessment_tag") | ||
write_result("version", "@version") | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
write_result("mnch_onboarding_dma_form_v1.0_started", "yes") | ||
v_start = concatenate(slug, "_", version, "_started") | ||
write_result("started", "@config.items.assessment_tag", label: "@v_start") | ||
write_result("locale", "@locale") | ||
end | ||
|
||
|
@@ -140,8 +140,8 @@ card CheckEnd when question_num == count(questions), then: End do | |
|
||
# workaround because the percentage calculation will throw a division by 0 error if max_score is 0 in either an if or a when clause. | ||
score_perc = score / max(max_score, 1) * 100 | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
write_result("mnch_onboarding_dma_form_v1.0_completed", "yes") | ||
slug_end = concatenate(slug, "_", version, "_end") | ||
write_result("slug", "@assessment_data.slug", label: "@slug_end") | ||
end | ||
|
||
card CheckEnd do | ||
|
@@ -297,7 +297,7 @@ end | |
|
||
card QuestionError | ||
when questions[question_num].question_type == "integer_question" and | ||
@question_response != lower("skip"), | ||
lower("@question_response") != "skip", | ||
then: CheckEnd do | ||
log( | ||
"Invalid input for integer_question: @question_response. Required value between @min and @max." | ||
|
@@ -314,7 +314,7 @@ end | |
|
||
card QuestionError | ||
when questions[question_num].question_type == "year_of_birth_question" and | ||
@question_response != lower("skip"), | ||
lower("@question_response") != "skip", | ||
then: CheckEnd do | ||
log( | ||
"Invalid input for year_of_birth_question: @question_response. Required value between @lower_bound_year and @get_year" | ||
|
@@ -342,13 +342,17 @@ card QuestionError when has_all_members(keywords, [@question_response]), then: C | |
text("@explainer") | ||
end | ||
|
||
card QuestionError when @question_response == lower("skip"), then: StoreResponse do | ||
card QuestionError when lower("@question_response") == "skip", then: StoreResponse do | ||
# If they skip a question we should | ||
# - record the answer as "skip" | ||
# - increment skip count | ||
# - do not count the question towards the score | ||
# - do not add the max score for this question (i.e. completely exclude this question from scoring) | ||
result_tag = concatenate("@slug", "_", "@version", "_question_num") | ||
write_result("question_num", question_num, label: "@result_tag") | ||
question_id = questions[question_num].semantic_id | ||
result_tag = concatenate("@slug", "_", "@version", "_", "@question_id") | ||
write_result("question_id", "skip", label: "@result_tag") | ||
skip_count = skip_count + 1 | ||
|
||
log("Skipping question @question_num") | ||
|
@@ -390,7 +394,11 @@ card CheckEndMultiselect | |
then: StoreResponse do | ||
question_num = question_num + 1 | ||
# write the answer results | ||
result_tag = concatenate("@slug", "_", "@version", "question_num") | ||
write_result("question_num", question_num, label: "@result_tag") | ||
question_id = questions[question_num].semantic_id | ||
result_tag = concatenate("@slug", "_", "@version", "_", "@question_id") | ||
write_result("question_id", "@multiselect_answer", label: "@result_tag") | ||
log("Answered @multiselect_answer to question @question_num") | ||
end | ||
|
||
|
@@ -441,7 +449,11 @@ card MultiselectError when lower(@question_response) == "skip", then: CheckEndMu | |
# - increment skip_count | ||
# - do not count the question towards the score | ||
# - do not add the max score for this question (i.e. completely exclude this question from scoring) | ||
result_tag = concatenate("@slug", "_", "@version", "question_num") | ||
write_result("question_num", question_num, label: "@result_tag") | ||
question_id = questions[question_num].semantic_id | ||
result_tag = concatenate("@slug", "_", "@version", "_", "@question_id") | ||
write_result("question_id", "skip", label: "@result_tag") | ||
|
||
skip_count = skip_count + 1 | ||
|
||
|
@@ -500,20 +512,40 @@ We record the following Flow Results: | |
card QuestionResponse when questions[question_num].question_type == "integer_question", | ||
then: StoreResponse do | ||
question_id = questions[question_num].semantic_id | ||
result_tag = concatenate("@slug", "_", "@version", "_question_num") | ||
write_result("question_num", question_num, label: "@result_tag") | ||
result_tag = concatenate("@slug", "_", "@version", "_question") | ||
write_result("question", question.question, label: "@result_tag") | ||
result_tag = concatenate("@slug", "_", "@version", "_", "@question_id") | ||
write_result("@result_tag", "@question_response") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to change this one to also using a label, so that we don't have |
||
result_tag = concatenate("@slug", "_", "@version", "_min") | ||
write_result("min", min, label: "@result_tag") | ||
result_tag = concatenate("@slug", "_", "@version", "_max") | ||
write_result("max", max, label: "@result_tag") | ||
|
||
question_num = question_num + 1 | ||
end | ||
|
||
card QuestionResponse when questions[question_num].question_type == "freetext_question", | ||
then: StoreResponse do | ||
question_id = questions[question_num].semantic_id | ||
result_tag = concatenate("@slug", "_", "@version", "_question_num") | ||
write_result("question_num", question_num, label: "@result_tag") | ||
result_tag = concatenate("@slug", "_", "@version", "_question") | ||
write_result("question", question.question, label: "@result_tag") | ||
result_tag = concatenate("@slug", "_", "@version", "_", "@question_id") | ||
write_result("question_id", "@question_response", label: "@result_tag") | ||
|
||
question_num = question_num + 1 | ||
end | ||
|
||
card QuestionResponse when questions[question_num].question_type == "age_question", | ||
then: StoreResponse do | ||
question_id = questions[question_num].semantic_id | ||
result_tag = concatenate("@slug", "_", "@version", "_question_num") | ||
write_result("question_num", question_num, label: "@result_tag") | ||
result_tag = concatenate("@slug", "_", "@version", "_", "@question_id") | ||
write_result("question_id", "@question_response", label: "@result_tag") | ||
log("Answered @age to question @question_num") | ||
|
||
question_num = question_num + 1 | ||
|
@@ -522,6 +554,12 @@ end | |
card QuestionResponse when questions[question_num].question_type == "year_of_birth_question", | ||
then: StoreResponse do | ||
question_id = questions[question_num].semantic_id | ||
result_tag = concatenate("@slug", "_", "@version", "_question_num") | ||
write_result("question_num", question_num, label: "@result_tag") | ||
result_tag = concatenate("@slug", "_", "@version", "_question") | ||
write_result("question", question.question, label: "@result_tag") | ||
result_tag = concatenate("@slug", "_", "@version", "_", "@question_id") | ||
write_result("question_id", "@question_response", label: "@result_tag") | ||
|
||
question_num = question_num + 1 | ||
end | ||
|
@@ -533,7 +571,11 @@ card QuestionResponse | |
then: CheckEnd do | ||
log("Skipping to end of Form") | ||
answer = find(question.answers, &(&1.answer == question_response)) | ||
result_tag = concatenate("@slug", "_", "@version", "_question_num") | ||
write_result("question_num", question_num, label: "@result_tag") | ||
question_id = questions[question_num].semantic_id | ||
result_tag = concatenate("@slug", "_", "@version", "_", "@question_id") | ||
write_result("question_id", "@question_response", label: "@result_tag") | ||
log("Answered @answer.answer to question @question_num") | ||
|
||
score = score + answer.score | ||
|
@@ -546,7 +588,11 @@ card QuestionResponse when lower("@question_response") == "skip", then: StoreRes | |
# - increment skip_count | ||
# - do not count the question towards the score | ||
# - do not add the max score for this question (i.e. completely exclude this question from scoring) | ||
result_tag = concatenate("@slug", "_", "@version", "_question_num") | ||
write_result("question_num", question_num, label: "@result_tag") | ||
question_id = questions[question_num].semantic_id | ||
result_tag = concatenate("@slug", "_", "@version", "_", "@question_id") | ||
write_result("question_id", "skip", label: "@result_tag") | ||
|
||
skip_count = skip_count + 1 | ||
|
||
|
@@ -561,6 +607,13 @@ card QuestionResponse, then: StoreResponse do | |
max_question_score = reduce(scores, scores[0], &max(&1, &2)) | ||
answer = find(question.answers, &(&1.answer == question_response)) | ||
question_id = questions[question_num].semantic_id | ||
|
||
result_tag = concatenate("@slug", "_", "@version", "_question_num") | ||
write_result("question_num", question_num, label: "@result_tag") | ||
# for multiple choice and categorical questions, save the semantic_id | ||
result_tag = concatenate("@slug", "_", "@version", "_", "@question_id") | ||
write_result("question_id", answer.semantic_id, label: "@result_tag") | ||
|
||
log("Answered @answer.answer to question @question_num") | ||
|
||
max_score = max_score + max_question_score | ||
|
@@ -577,46 +630,26 @@ These cards are to configure storing the answers of the Form in contact fields. | |
|
||
```stack | ||
card StoreResponse when question_id == "dma-do-things" do | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
answer = filter(question.answers, &(&1.answer == question_response)) | ||
semantic_id = if(count(answer) == 0, "skip", answer[0].semantic_id) | ||
write_result("mnch_onboarding_dma_form_v1.0_dma-do-things", semantic_id) | ||
update_contact(dma_01: "@question_response") | ||
then(CheckEnd) | ||
end | ||
|
||
card StoreResponse when question_id == "dma-medical-care" do | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
answer = filter(question.answers, &(&1.answer == question_response)) | ||
semantic_id = if(count(answer) == 0, "skip", answer[0].semantic_id) | ||
write_result("mnch_onboarding_dma_form_v1.0_dma-medical-care", semantic_id) | ||
update_contact(dma_02: "@question_response") | ||
then(CheckEnd) | ||
end | ||
|
||
card StoreResponse when question_id == "dma-sharing" do | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
answer = filter(question.answers, &(&1.answer == question_response)) | ||
semantic_id = if(count(answer) == 0, "skip", answer[0].semantic_id) | ||
write_result("mnch_onboarding_dma_form_v1.0_dma-sharing", semantic_id) | ||
update_contact(dma_03: "@question_response") | ||
then(CheckEnd) | ||
end | ||
|
||
card StoreResponse when question_id == "dma-medical-advice" do | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
answer = filter(question.answers, &(&1.answer == question_response)) | ||
semantic_id = if(count(answer) == 0, "skip", answer[0].semantic_id) | ||
write_result("mnch_onboarding_dma_form_v1.0_dma-medical-advice", semantic_id) | ||
update_contact(dma_04: "@question_response") | ||
then(CheckEnd) | ||
end | ||
|
||
card StoreResponse when question_id == "dma-find-solutions" do | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
answer = filter(question.answers, &(&1.answer == question_response)) | ||
semantic_id = if(count(answer) == 0, "skip", answer[0].semantic_id) | ||
write_result("mnch_onboarding_dma_form_v1.0_dma-find-solutions", semantic_id) | ||
update_contact(dma_05: "@question_response") | ||
then(CheckEnd) | ||
end | ||
|
@@ -640,8 +673,8 @@ We record the following Flow Results: | |
card End | ||
when skip_count < skip_threshold and | ||
score_perc >= assessment_data.high_inflection do | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
write_result("mnch_onboarding_dma_form_v1.0_risk", "high") | ||
result_tag = concatenate("@slug", "_", "@version", "_risk") | ||
write_result("risk", "high", label: "@result_tag") | ||
log("Assessment risk: high") | ||
page_id = assessment_data.high_result_page.id | ||
|
||
|
@@ -652,36 +685,37 @@ card End | |
when skip_count < skip_threshold and | ||
score_perc >= assessment_data.medium_inflection and | ||
score_perc < assessment_data.high_inflection do | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
write_result("mnch_onboarding_dma_form_v1.0_risk", "medium") | ||
result_tag = concatenate("@slug", "_", "@version", "_risk") | ||
write_result("risk", "medium", label: "@result_tag") | ||
log("Assessment risk: medium") | ||
page_id = assessment_data.medium_result_page.id | ||
|
||
then(DisplayEndPage) | ||
end | ||
|
||
card End when skip_count >= skip_threshold do | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
write_result("mnch_onboarding_dma_form_v1.0_risk", "skip_high") | ||
result_tag = concatenate("@slug", "_", "@version", "_risk") | ||
write_result("risk", "skip_high", label: "@result_tag") | ||
log("Assessment risk: skip_high") | ||
page_id = assessment_data.skip_high_result_page.id | ||
|
||
then(DisplayEndPage) | ||
end | ||
|
||
card End do | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
write_result("mnch_onboarding_dma_form_v1.0_risk", "low") | ||
result_tag = concatenate("@slug", "_", "@version", "_risk") | ||
write_result("risk", "low", label: "@result_tag") | ||
log("Assessment risk: low") | ||
page_id = assessment_data.low_result_page.id | ||
|
||
then(DisplayEndPage) | ||
end | ||
|
||
card DisplayEndPage do | ||
# TODO: remove this hard-coding once we can have dynamic labels for flow results | ||
write_result("mnch_onboarding_dma_form_v1.0_score", score) | ||
write_result("mnch_onboarding_dma_form_v1.0_max_score", max_score) | ||
result_tag = concatenate("@slug", "_", "@version", "_score") | ||
write_result("score", score, label: "@result_tag") | ||
result_tag = concatenate("@slug", "_", "@version", "_max_score") | ||
write_result("max_score", max_score, label: "@result_tag") | ||
|
||
response = | ||
get("https://content-repo-api-qa.prk-k8s.prd-p6t.org/api/v2/pages/@page_id/", | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we rather have the answer key be
end
instead ofslug
? To keep the naming consistent.