Skip to content

Commit

Permalink
Merge pull request #28 from praekeltfoundation/feature/DELTA-1490/qui…
Browse files Browse the repository at this point in the history
…z-functionality

Quiz functionality
  • Loading branch information
rudigiesler authored Jan 13, 2025
2 parents 7d268e0 + 2d59224 commit a627c08
Show file tree
Hide file tree
Showing 4 changed files with 3,557 additions and 2,757 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: praekeltfoundation/flow_tester
ref: v0.3.6
ref: v0.4.3
path: flow_tester
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Check formatting
Expand Down
50 changes: 41 additions & 9 deletions Forms/QA/flows/DMA Form.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ version: "0.1.0"
columns: []
-->

| Key | Value |
| -------------- | -------- |
| assessment_tag | dma_form |
| Key | Value |
| -------------------- | ------------- |
| assessment_tag | dma_form |
| response_button_text | Next question |

## Get Assessment

Expand Down Expand Up @@ -508,6 +509,8 @@ We record the following Flow Results:
* `question_num`, the question number
* `answer`, the final answer which will be a comma separated list of all the answers that were selected

If it's a choice selection question type that has a `response`, then we show the user the response before moving on to the next question.

```stack
card QuestionResponse when questions[question_num].question_type == "integer_question",
then: StoreResponse do
Expand Down Expand Up @@ -602,7 +605,7 @@ card QuestionResponse when lower("@question_response") == "skip", then: StoreRes
question_num = question_num + 1
end
card QuestionResponse, then: StoreResponse do
card QuestionResponse, then: DisplayResponse do
scores = map(question.answers, & &1.score)
max_question_score = reduce(scores, scores[0], &max(&1, &2))
answer = find(question.answers, &(&1.answer == question_response))
Expand All @@ -622,6 +625,16 @@ card QuestionResponse, then: StoreResponse do
question_num = question_num + 1
end
card DisplayResponse when has_text(answer.response), then: StoreResponse do
buttons(StoreResponse: "@config.items.response_button_text") do
text("@answer.response")
end
end
card DisplayResponse do
then(StoreResponse)
end
```

## Store Response
Expand Down Expand Up @@ -678,7 +691,7 @@ card End
log("Assessment risk: high")
page_id = assessment_data.high_result_page.id
then(DisplayEndPage)
then(FetchEndPage)
end
card End
Expand All @@ -690,7 +703,7 @@ card End
log("Assessment risk: medium")
page_id = assessment_data.medium_result_page.id
then(DisplayEndPage)
then(FetchEndPage)
end
card End when skip_count >= skip_threshold do
Expand All @@ -699,7 +712,7 @@ card End when skip_count >= skip_threshold do
log("Assessment risk: skip_high")
page_id = assessment_data.skip_high_result_page.id
then(DisplayEndPage)
then(FetchEndPage)
end
card End do
Expand All @@ -708,10 +721,10 @@ card End do
log("Assessment risk: low")
page_id = assessment_data.low_result_page.id
then(DisplayEndPage)
then(FetchEndPage)
end
card DisplayEndPage do
card FetchEndPage, then: DisplayEndPage do
result_tag = concatenate("@slug", "_", "@version", "_score")
write_result("score", score, label: "@result_tag")
result_tag = concatenate("@slug", "_", "@version", "_max_score")
Expand All @@ -732,6 +745,25 @@ card DisplayEndPage do
log("@page_id")
message_body = response.body.body.text.value.message
image_id = response.body.body.text.value.image
end
card DisplayEndPage when isnumber(image_id) do
image_response =
get("https://content-repo-api-qa.prk-k8s.prd-p6t.org/api/v2/images/@image_id/",
timeout: 5_000,
cache_ttl: 60_000,
headers: [
["content-type", "application/json"],
["authorization", "Token @global.config.contentrepo_token"]
]
)
image("@image_response.body.meta.download_url")
text("@message_body")
end
card DisplayEndPage do
text("@message_body")
end
Expand Down
Loading

0 comments on commit a627c08

Please sign in to comment.