B4J Question Dynamic Variables in text to be stored and retrieved. Approach 2 of 3

paragkini

Member
Licensed User
Longtime User
Hello friends,
Need your views on the app that I am developing for my kids to do their home work or study practice.
This is an app which will have questios-answers, fill in the blanks and select correct options.
While question-answers category is pretty straight forward, fill in the blanks and choose option is a bit tricky (for me).
I have worked on different approaches to handle these questions and almost ready to start the development.
However just thought of presenting this to you all for your views so that I can get some inputs or find out any flaws in the approach which I can correct.
I will create three different threads to ensure discussions are not mixed up. (I hope that should be ok with the rules of the group)

Requirement 1
Requirement 2
Requirement 3

This thread is the 2 of the 3 threads (subsequently, approaches)
Would appreciate your feedback on the these approaches.

Requirement 2:
Options with formula (B4X Sub name) to display return value processed through the code. Similar to Excel formula.

Example:
Main Text :
While playing in the garden, John collected 7 flowers, Agatha collected 9 and Angela collected 8 flowers.
What is the total number of flowers they collected?

Save Text :
While playing in the garden, [={ReturnRandomNameBoy}] collected 7 flowers,
[={ReturnRandomNameGirl}] collected 9 and [={ReturnRandomNameGirl}] collected 8 flowers.
What is the total number of flowers they collected?

Display :
While playing in the garden, John collected 7 flowers, Agatha collected 9 and Angela collected 8 flowers.
What is the total number of flowers they collected?


Where :

[={ReturnRandomNameBoy}] = John (this value is returned from database through sub. values eg. John/Albert/Pinto etc.
[={ReturnRandomNameGirl}] = Albert(this value is returned from database through sub. values eg. Margaret/Agatha/Angela etc.


Future changes :

Approach:
SubNames with parameters. e.g.
=ReturnRandomName("Boy") OR =ReturnRandomName("Girl") OR =ReturnRandomName("Dog")
=ReturnRandomName("Place") OR =ReturnRandomName("City") OR =ReturnRandomName("Object")


Objective:
I don't want to give static values everytime. It should be changing every time the question is attempted.

Usage:
=ReturnRandomNumbers(Slices, Total) : Usage below
=ReturnRandomNumbers(3,100)

This sub will return 3 random numbers having total of 100.

e.g. :
Number 1 = 33
Number 2 = 45
Number 3 = 22
[33+45+22 = 100]


Usage (using example above):

Main Text :
While playing in the garden, John collected 33 flowers, Agatha collected 45 and Angela collected 22 flowers.
Total number of flowers collected by them is 100.

Save Text :
While playing in the garden, [={ReturnRandomName("Boy")}] collected [#{1}] flowers,
[={ReturnRandomName("Girl")}] collected [#{2}]
and [={ReturnRandomName("Dog")}] collected [#{3}] flowers.
What is the total number of flowers they collected?
Total number of flowers collected by them is [={ReturnRandomNumbers(3,100)}].

Display :
While playing in the garden, John collected 33 flowers, Agatha collected 45 and Angela collected 22 flowers.
Total number of flowers collected by them is ___.


[#{1}] = 33
[#{2}] = 45
[#{3}] = 22



Again, any suggestion, help would be appreciated.
 
Last edited:
Top