Quantcast
Channel: General developer forum
Viewing all articles
Browse latest Browse all 37677

Re: Is it possible to get quiz id in formulation_and_controls (renderer.php) of a question type?

$
0
0
by Tim Hunt.  

Maria messaged me privately (Grrrr!)

Here is the issue of the question type I am upgrading:

I'm trying to assing different data to different students from one question. I define the question and when I put it in the quiz the plugin assign different data (which is stored in the database) to the users when they try to attempt the quiz. That is why someone create the customize_problem_statement and why she use the quiz id to specify the data for each user. In 1.9 it used to function correctly but I can't find the way to upgrade it to 2.3.

The correct way to assign different data to different students is demonstrated by a number of question types: calcuated in Moodle core, and varnumset and stack as add-ons.

In your question class, you first need to override the get_num_variants method, to return the number of data sets that you have. Then, the $variant passed to start_attempt will be a number between 1 and get_num_variants inclusive. You can use that to customize_problem_statement.

How do you handle the situation where you want all the questions in the quiz to use the same data set for a particular student. Well, that is where the get_variants_selection_seed method comes in. If two questions in the same quiz return the same value from get_variants_selection_seed, and have the same number of variants, then the $variant passed to start_attemtp will be the same for both questions in one quiz attempt.


Viewing all articles
Browse latest Browse all 37677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>