Skip to content

Commit f8ae816

Browse files
authored
Feature/documentation fixes (#60)
* fixes to doco.
1 parent 5be7848 commit f8ae816

File tree

7 files changed

+56
-27
lines changed

7 files changed

+56
-27
lines changed

Manual.md

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,31 @@
44

55
# Rules as Code Webform OpenFisca Drupal module User manual
66

7-
7+
<!-- TOC -->
8+
9+
* [Rules as Code Webform OpenFisca Drupal module User manual](#rules-as-code-webform-openfisca-drupal-module-user-manual)
10+
* [Course objectives](#course-objectives)
11+
* [About Rules as Code](#about-rules-as-code)
12+
* [The RaC process](#the-rac-process)
13+
* [Our scenarios/use cases](#our-scenariosuse-cases)
14+
* [About Drupal and Rules as Code](#about-drupal-and-rules-as-code)
15+
* [About the OpenFisca API](#about-the-openfisca-api)
16+
* [Analysing the API requirements](#analysing-the-api-requirements)
17+
* [1\. Entities](#1-entities)
18+
* [2\. Variables](#2-variables)
19+
* [Creating a webform](#creating-a-webform)
20+
21+
22+
* [Creating RaC content](#creating-rac-content)
23+
* [Creating results page (intro)](#creating-results-page-intro)
24+
* [Redirection rules (intro)](#redirection-rules-intro)
25+
* [Test the webform](#test-the-webform)
26+
* [Tokens](#tokens)
27+
* [Results blocks](#results-blocks)
28+
* [Testing the demo webforms](#testing-the-demo-webforms)
29+
* [Conclusion](#conclusion)
30+
* [Further references](#further-references)
31+
<!-- TOC -->
832

933
# Course objectives
1034

@@ -203,11 +227,9 @@ Once you’ve analysed the API, you’re ready to start the process of creating
203227
7. Click "Add handler"
204228
![](assets/create-webform-6.png)
205229

206-
8. Click "Add handler" against the OpenFisca Journey handler
207-
This step will ensure that the webform goes through OpenFisca processing.
230+
8. Click "Add handler" against the OpenFisca Journey handler - this step will ensure that the webform goes through OpenFisca processing.\
208231
![](assets/create-webform-7.png)
209-
210-
9. Click Save
232+
9. Click Save\
211233
![](assets/create-webform-8.png)
212234

213235
10. Now we need to add details of the OpenFisca API. Click "General"
@@ -232,7 +254,7 @@ You can disable the saving of submission data in the “General Settings” on
232254
![](assets/create-webform-12.png)
233255

234256
When **Enable debug mode** is checked, the result page will show debug information like the screenshot below:
235-
![](assets/debug-1.png)
257+
![](assets/debug-1.png)\
236258
This information can help when you’re testing to see if the webform is returning the result you expect.
237259

238260
When **Log OpenFisca calculation** is checked, this information is sent for DB logging.
@@ -254,7 +276,9 @@ need to be fully qualified.
254276
In our case, (for now) they are:
255277

256278
```
257-
persons.personA.disability_allowance_eligible persons.personA.disability_allowance_benefit persons.personA.monthly_income_exceeds_limit
279+
persons.personA.disability_allowance_eligible
280+
persons.personA.disability_allowance_benefit
281+
persons.personA.monthly_income_exceeds_limit
258282
```
259283

260284
We will come back later and update this value once we start working on block visibility.
@@ -293,7 +317,7 @@ We will come back later and update this value once we start working on block vis
293317
27. Let’s name the field aus\_citizen\_or\_permanent\_resident
294318
![](assets/build-5.jpeg)
295319

296-
28. Add the options for the field. Please note that in this case, we are using prefix and suffix for the field to improve the UX of the webform.
320+
28. Add the options for the field. Please note that in this case, we are using prefix and suffix for the field to improve the UX of the webform.\
297321
![](assets/build-6.png)
298322

299323
29. Now, we need to associate it to an OpenFisca variable. Scroll down and click this dropdown.
@@ -302,35 +326,36 @@ We will come back later and update this value once we start working on block vis
302326
30. When you click the dropdown, you will see a list of variables defined in the OpenFisca API, which was defined earlier.
303327
![](assets/build-8.png)
304328

305-
31. Select the appropriate variable from the dropdown
329+
31. Select the appropriate variable from the dropdown\
306330
![](assets/build-11.jpeg)
307331

308-
32. Next, we need to enter the entity name. Click the "Fisca entity key" field.
332+
32. Next, we need to enter the entity name. Click the "Fisca entity key" field.\
309333
![](assets/build-12.png)
310334

311-
33. Type PersonA
335+
33. Type PersonA\
312336
![](assets/build-13.jpeg)
313337

314338
34. Next we go ahead and add all the other variables to the webform.
315339

316340
35. Now we need to add the return variables as hidden fields.
317-
So we search for "hidden" and click "Add element"
341+
So we search for "hidden" and click "Add element"\
318342
![](assets/build-14.png)
319343

320-
36. This is the return variable if the person qualifies for disability allowance or not.
344+
36. This is the return variable if the person qualifies for disability allowance or not.\
321345
![](assets/build-15.png)
322346

323-
37. We will associate the OpenFisca variable to this as well:
347+
37. We will associate the OpenFisca variable to this as well:\
324348
![](assets/build-16.png)
325349

326350

327351
38. We will follow the same process and add the 2 more return variables we need.
328352
disability\_allowance\_benefit and monthly\_income\_exceeds\_limit
329353

330-
39. You may or may not want to add conditional visibility options for the form. E.g. if the user says that they are NOT an AUS citizen or resident, we might want to show them a “You are not eligible” message and not show them the Submit button. For this, you can add a markup like this
354+
39. You may or may not want to add conditional visibility options for the form. E.g. if the user says that they are NOT an AUS citizen or resident, we might want to show them a “You are not eligible” message and not show them the Submit button. For this, you can add a markup like this\
331355
![](assets/build-17.png)
332356

333-
And configure conditions like this: ![](assets/build-18.png)
357+
And configure conditions like this:\
358+
![](assets/build-18.png)
334359

335360
40. The form is now created. Below is a screenshot of what it looks like in the frontend of the website.
336361
![](assets/build-19.png)
@@ -385,7 +410,7 @@ In our use case, the user can either be eligible or not eligible for disability
385410
![](assets/content-1.jpeg)
386411
![](assets/content-2.jpeg)
387412
![](assets/content-3.jpeg)
388-
2. Add an relevant title (You are eligible) and accompanying content and then click **Save**.
413+
2. Add a relevant title (You are eligible) and accompanying content and then click **Save**.
389414
![](assets/content-4.jpeg)
390415
3. Similarly, create another page for not eligible with a title (You are not eligible) and relevant content, and then click **Save**.
391416

@@ -419,7 +444,9 @@ Payload:
419444

420445
![](assets/debug-2.png)
421446

422-
Response:![](assets/debug-3.png)
447+
Response:
448+
449+
![](assets/debug-3.png)
423450

424451
Results:
425452

@@ -433,8 +460,9 @@ The content of the results page can be customised as required.
433460

434461
OpenFisca also has a concept of **Parameters**. A parameter is a property of the legislation that changes over time. Unlike a variable, a parameter is not specific to a specific entity (e.g. person, household).
435462

436-
In our use case, one of the parameters would be the disability allowance benefit. ![][image60]
463+
In our use case, one of the parameters would be the disability allowance benefit.
437464

465+
![](assets/tokens-4.png)
438466
The module allows us to expose certain parameters as tokens as well, so that they can be shown in the result pages. This can improve the user experience by giving the user as much information as possible when showing results.
439467

440468
You will need to enable the module [Token Filter](https://www.drupal.org/project/token_filter) and then add tokens on the page to show more details.
@@ -488,7 +516,7 @@ So, before we start this exercise, the website builder/developer for the website
488516

489517
![](assets/block-1.png)
490518

491-
This points to the paragraph **Block RAC Elements.**
519+
This points to the paragraph **Block RAC Elements.**\
492520
![](assets/block-2.png)
493521

494522

@@ -500,7 +528,7 @@ Let’s start with use case 1 mentioned above:
500528
You are not eligible because your income exceeds a minimum amount (defined as a parameter in OpenFisca). Response from OpenFisca would have these values:
501529

502530
1. disability\_allowance\_eligible=0
503-
2. monthly\_income\_exceeds\_limit=1
531+
2. monthly\_income\_exceeds\_limit=1
504532

505533
**Note**:
506534

@@ -530,18 +558,18 @@ For block creation you can follow the steps below.
530558

531559
The variables need to be fully qualified. So persons.personA.disability\_allowance\_eligible and not disability\_allowance\_eligible
532560

533-
This interface can cater for a complex set of conditions, when we want to check for operators other than \=
561+
This interface can cater for a complex set of conditions, when we want to check for operators other than \= \
534562
![](assets/block-11.png)
535563

536564
We can add multiple conditions, which need to be an ORed or XORed (instead of AND)
537565

538566
![](assets/block-12.png)
539567

540-
We can also add multiple sets of conditions, and use AND/ OR/ XOR between them.
568+
We can also add multiple sets of conditions, and use AND/ OR/ XOR between them.\
541569
![](assets/block-13.png)
542570

543571
7. Save the Block.
544-
8. Now, let’s place the block. Go to Block layout![][image77]
572+
8. Now, let’s place the block. Go to Block layout
545573

546574
![](assets/block-14.jpeg) ![](assets/block-15.jpeg)
547575

@@ -576,7 +604,7 @@ As you can see in the screenshot above, the ‘Income exceeds limit’ block we
576604

577605
Once you’ve created the webform it’s time for testing (quality assurance). Part of the early business analyst work is to create test cases that the OpenFisca developers use when writing the code. These test cases can be re-used by adding the inputs to the frontend webform.
578606

579-
Below is a screenshot of test cases prepared for the ACT.
607+
Below is a screenshot of test cases prepared for the ACT use case.
580608

581609
![](assets/test-1.png)
582610

@@ -597,9 +625,10 @@ Add in the required values to the webform and then click on Submit.
597625
We’re expecting a result of **eligible** and a dollar figure of $200.
598626
![](assets/test-4.png)
599627

600-
## Exercise: testing the webform
628+
[//]: # (## Exercise: testing the webform)
601629

602-
Now test the second scenario from above in the webform. You’re expecting a result of Not eligible with the ‘income too high’ block.
630+
[//]: # ()
631+
[//]: # (Now test the second scenario from above in the webform. You’re expecting a result of Not eligible with the ‘income too high’ block.)
603632

604633
# Conclusion
605634

assets/build-12.png

-12.2 KB
Loading

assets/build-17.png

-26.3 KB
Loading

assets/build-18.png

-28.6 KB
Loading

assets/create-webform-18.png

-19.8 KB
Loading

assets/create-webform-19.png

-7.86 KB
Loading

assets/tokens-4.png

28.7 KB
Loading

0 commit comments

Comments
 (0)