Formulas Character string and Pick Index

Formulas Character string and Pick Index

by Dipo Adeniyi -
Number of replies: 2

Good Morning,

Just wondering if this is possible:

Trying to use Moodle Formulas with string as answer with pick index (type in), already works well with multiple choice. Pls find below what I have done (Using example from here:  Character string answer

I'm however struggling to get pick index to recognise the correct answer to each question when type in rather than select from multiple choice.

Example: if "Where aerobic respiration occurs" is randomly selected, student should be able to type in "mitochondrion"

If "Sub cellular organisms for protein synthesis" is randomly selected, student should be able to type in "ribosomes"

I shall be very grateful for any help regarding the above. Question file attached.

Text as answer

Average of ratings: -
In reply to Dipo Adeniyi

Re: Formulas Character string and Pick Index

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello Dipo,

In your question, you can use the pick() function if you want, but it's not necessary. Simply refer to an element in the array using its index.

A string answer type has not yet been implemented in the Formulas question. Until it is, we can use a workaround for one or two word strings that is to use a variable name as the answer in an algebraic formula answer type. The variable is set to any arbitrary value that is not used. Only the name of the variable is used.

In the following example, I also added a small script to make the answers case-insensitive.

Try the question here ↗.

ForumQuiz_20211001_2346.png

Average of ratings: Useful (1)
In reply to Dominique Bauer

Re: Formulas Character string and Pick Index

by Dipo Adeniyi -
Thanks so much Dominique.

I deeply appreciate this.