System variables in Formulas question types

System variables in Formulas question types

by Mark Stringer -
Number of replies: 6

Hi, 


I would like to create a quiz which links together several different formulas type questions, but which would use a common set of randomly generated variables. 


For instance if I have 3 questions, I might have a variable "a" which is randomly generated for a particular user, but then the same value of "a" is used in all three questions.  Is this possible?


Alternatively, is there a way to access system variables (such as User ID) within a formulas question type?  If that is possible, then I can generate ahead of time a series of random variables, and then use the USER ID to select which value to use....


thanks in advance,


Mark

Average of ratings: -
In reply to Mark Stringer

Re: System variables in Formulas question types

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Mark,

With the formula type question, the setup you describe can be done in just one question instead of 3 separate questions. In other words, you can make one question that requires the student to provide multiple answers. I know I have made some questions that required up to a dozen inputs from a student.

As for the USER ID, I am not sure. I know that the Generico filter can get you users first and last names which makes it possible to personalize lots of things in Moodle, but I am not sure about it getting the USER ID. If I were to guess, I would say it probably could.

In reply to Mark Stringer

Re: System variables in Formulas question types

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

Hi Mark,

I agree with Al.

No, I far as I know, it is not possible to have the same set of randomly generated variables in different Formulas type questions. I do not know how to access system variables, such as User ID, or if it is readily feasible.

However, you should consider using the "Parts" in the Formulas type questions. You can have as many parts as you want. Parts can use the global variables and local variables (displayed with 'Show more'). Parts have their own text and feedback, and can have multiple answers. They can be thought of as different questions sharing the same random variables. Note that parts can only be displayed on the same page and that they share the same [Check] button.

If required, the quiz can be attempted during different sessions, with the same set of random variables, by setting the quiz's 'Attempts allowed' to 3 for example, 'Grading method' to Highest grade, 'Each attempt builds on the last' to Yes and the 'How questions behave' to Adaptive mode which allows students to check one or more answers at a time.

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

Re: System variables in Formulas question types

by Jean-Michel Védrine -

Hello Mark,

Dominique is right, it is not possible to have the same set of randomly generated variables in several questions.

But as Dominique pointed out you can have as many parts as you want in one unique formulas question. And I must add that a part is not just an input, a part can have several inputs for instance student can enter all the numbers of a matrix as just the answer to one part of a formulas question.

Another advice when the question has several parts is to use the adaptive behaviour because even if the question has one unique "Check" button students can just enter an answer for the first part and use the Check button to test this answer. There will be no penalty for the not yet answered other parts. Also if a student has the same wrong answer to one part for several "Checks" there will not be multiple penalty.

You are the first one to ask the ability to access system variables like user ID. Of course it could be done but to be honest I don't think I will be able to find the time to do it.

In fact for several months I have not been able to find the time to work on the formulas question type code.

My problem is that you can't just say "This afternoon I will work on Formulas", to be productive I need to find some hours during several days to first remind me of the current state of the code, read my notes and my todo list and begin to work, and when something is finished I need to do some tests to verify I have not broken something.

This explain why for instance I have not yet been able to work on the feedback problems submitted by Dominique Bauer (Sorry Dominique !).

On the contrary I am still working on some Moodle coding smaller tasks that only require a few hours of work, for instance this week I submitted a new feature: export of multichoice questions with Aiken format (MDL-21904) but this is all I can currently do.

Average of ratings: Useful (3)
In reply to Jean-Michel Védrine

Re: System variables in Formulas question types

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I might be a little off-target from what Mark is asking, but I do want to add some ideas that might help.

If the question is "Can a set of variables, such as x, y, z, be used across a group of questions?" the answer might be yes.  I say this because this is what I am doing with the Calculated Multichoice question type. 

For example, if one wants to use two randomly, let's say x and y, which might take on the values 4 and 5, and then ask: For a rectangle with sides of 4 and 5, 1) What is it's area?, 2) What is it's perimeter, and 3) What is it's maximum distance between corners?, this can be done.  All questions would use the values 4 and 5.

There are a few qualifiers for what I say.

1) Calculated Multichoice doesn't create the random variables on the fly, you create this "set" of randomly generated variables when you create the question.

2) The questions that are going to use the same set must be in the same question category.

Also, the Calculated Multichoice question type takes some study, like 8 hours of experimenting, to start appreciating what it can do. (So Jean-Michel, I can appreciate what you are saying about needing a block of time to get back into an issue.)

Having said this, I do want to add that I find this Calculated Multichoice question type to be one of the most powerful "Moodle built-in, supported" question type, meaning that it is not an add-in.

Well, hope some of this is helpful.

(Actually, I am thinking about giving a presentation at one of this year's MoodleMoots on this topic. Might anyone find this useful?)

In reply to Jean-Michel Védrine

Re: System variables in Formulas question types

by Mark Stringer -

Thanks everyone for your comments and suggestions!  

I wanted to keep the separation between the different questions largely because they were related to specific aspects of an overall problem (i.e the first question was deriving strength parameters for a soil, while the second part was using the strength parameters as inputs into a design problem.  In the end I decided to work around the issue by getting the students to input their values from the previous question as inputs into the different parts of the second question (i.e. the parts of the second question then had multiple answer inputs) and then used the grading variables to code in the correct response.  


A bit of a faff, which would have been slightly easier I guess within one contained question!


Jean-Michel, thanks for developing the formula question type to the state it's in at the moment - I find it generally very useful!


Best wishes,


Mark