Conditional answer fields (Moodle Formulas Q Type)

Conditional answer fields (Moodle Formulas Q Type)

by Ton Boerkoel -
Number of replies: 10

I am not sure if this can be done in Moodle Formulas:

I would like to create a question where for example I give an 3D affine transformation, and ask for the fixed points. I would first like to ask students:


and based on their answer present them with either


or


and then I also want the grading to be done appropriately smile  [ Even such that if they answer "line" when in reality it is a plane, but the direction vector they give for the line is also a direction vector for the plane they should get partial credit for that.]

So my questions is this:  is it possible to set up conditional answer fields like that (in the case of "line" there would be 6 answer fields and in case of "plane" there would be 9. )

One of the problems I imagine would be how to populate the "Answer" field, where we enter possible answers. In the first case we would need to show 6 answers, in the second case 9 answer.

Maybe I am stretching Moodle Formulas' capabilities ... but it would be really nice if this would be possible. It would open up an entirely new array of questions I can create. 

Average of ratings: -
In reply to Ton Boerkoel

Re: Conditional answer fields (Moodle Formulas Q Type)

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

In this case, the grades can be adjusted directly in the quiz without having to make any adjustments in the grade book. I would nevertheless like to clarify the marking for this problem.

Let us consider the three questions:

A: line or plane (radio buttons)
B: vector (6 answers)
C: plane (9 responses)

Although the student only has to answer two questions, Moodle will count all three. The three questions must therefore be taken into account when assigning marks.

Let us assume the following notation:

A: 3 pts. Answer: "plane" gets 3 pts, "line" gets 1 pt
B: 4 pts
C: 3 pts

The total score of the quiz is therefore 10 points.

If the student has everything right, his mark is 10/10.
If the student answers "plane" and gives a completely incorrect plane his mark is 6/10.

If the student answers "line" and gives the correct vector his mark is 8/10.
If the student answers "line" and gives a completely incorrect vector his mark is 5/10.

Obviously, you can adjust this marking, but if the principle suits you, we can go ahead.

I think the quiz is doable. However, you will need to do some JavaScript (which is not yet documented smile. In fact, you could deduce how to do it from existing examples on the Formulas website.

You mentioned that the information was scattered in several places. For this problem, the specific information on how to do it did not exist before you asked the question today on the forum. Now the information is only in my brain. I will share it soon on the forum and if I have time I will write a nice description on the Formulas website.
In reply to Dominique Bauer

Re: Conditional answer fields (Moodle Formulas Q Type)

by Ton Boerkoel -

Cool. So it is possible to have something appear conditionally. I'd be happy to deduce things from existing examples ... but I couldn't find them. I remember seeing someone mentioning a conditional field appearing but this afternoon when I was looking for it I couldn't find it. If you have a link it would be appreciated. You don't have to spend the time on it ... I'd be happy to figure it out ... from existing examples.

Yes I can see how the grading might be done. As to the possible answers that need to be provided, one might just give the 6 that are needed, and add zeros for the 3 that are not used (?)

The harder problem for me is how to get one of the two options to appear conditioned on the radio answers. And also I wouldn't know how to make Formulas not ask for the remaining answers. So far Formulas always insists to enter all fields (in the behavior I usually use: deferred feedback)

Thanks!

In reply to Ton Boerkoel

Re: Conditional answer fields (Moodle Formulas Q Type)

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

Hello Ton,

Here is a Formulas question which first asks to choose between two options, 'Line' or 'Plane'. The correct choice is 'Plane' which counts for 4 points. The incorrect choice 'Line' still gives the student 2 points.

If the student chooses 'Line', the question asks for the values of two coefficients which each count for 2 points. If the student chooses 'Plan', the question asks for the values of three coefficients which each count for 2 points.

So, if the student has chosen 'Line', the maximum possible score is 6 out of 10. If the student has chosen 'Plan', the maximum possible score is 10 out of 10. Of course, the marking scheme can be changed as desired.

You can try the question at https://moodleformulas.org/course/view.php?id=77§ion=9.


In reply to Dominique Bauer

Re: Conditional answer fields (Moodle Formulas Q Type)

by Ton Boerkoel -

Hi Dominique.

I will try to adapt this to the multi-part question I had in mind. I entered your script and noticed clicking the radio buttons put zeros in answer boxes in other parts of the question. I will have to carefully build on your setup and see if I can get it to work.

Thanks!

Ton


In reply to Ton Boerkoel

Re: Conditional answer fields (Moodle Formulas Q Type)

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

As you may have already realized, answers are required even for the hidden question for the method to work, and obviously those answers must be incorrect. You can use "0" or any number that you know will never be a correct answer, for example "-999". Since these are incorrect answers, it does not matter that they are generated on the client side by JavaScript and that students might find out by looking at the source code of the page (Ctrl-u, F12 and so on).

In "Interactive with multiple tries" mode, the system reminds students to fill in all the answers. If they don't, they can't pretend they weren't warned.

In "Deferred feedback" mode, the system does not display the reminder to complete all answers. If the students do not, the answers they provided are unfortunately not counted. There might be a way around this problem. This last method is not documented as I got the idea while I was writing this post and haven't even developed it yet.
In reply to Dominique Bauer

Re: Conditional answer fields (Moodle Formulas Q Type)

by David Galiana -
Hi Dominique

I adapted your code to one question of elementary math: solving 2nd degree equations.



Thank you for your code and the idea of hiding divs based on radio buttons.

I hope it helps.

David


In reply to David Galiana

Re: Conditional answer fields (Moodle Formulas Q Type)

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

Thanks for your question. I put it in the question bank and made some very minor edits. If you want to improve the question, please work with this latest version which you can download from the question bank.
In reply to Dominique Bauer

Re: Conditional answer fields (Moodle Formulas Q Type)

by Ton Boerkoel -

I am working on a quiz question, using your code, but I ran into a problem:

When you hit the radio choice, i.e. activate the code that fills answer fields with "" and enter "0" in the other answer fields, this is done globally to all answer fields in other parts as well:

Hence if a student just filled out the answer to part (a)


These answers in part (a)  get erased when they hit any of the radio buttons in (b)





In reply to Ton Boerkoel

Re: Conditional answer fields (Moodle Formulas Q Type)

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

Have you adjusted the jQuery selectors for the answer boxes? The selectors are :eq(), :gt() and :lt(). See w3schools ↗ for details. jQuery selectors refer to all answer boxes of the same class (number, numeric, numerical formula, algebraic formula) as they appear on the web page, always counting from 0.
In reply to Dominique Bauer

Re: Conditional answer fields (Moodle Formulas Q Type)

by Ton Boerkoel -

Yes I adjusted the gt() and l(t) to match my boxes, didn't know I needed to adjust the eq() too.