- , n]}, where n is a positive
integer.
Calling GiveQuestion causes Mathematica to sample from each of the parameter
sets associated with the specified question class, according to the following
rules:
* if the parameter set is of the first form, this sampling is done by means of
a simple call to Random;
* if it is of the second form, one of the specified values is chosen, each with
equal probability;
* if it is of the third form, one of the values specified in the first vector
is chosen, with a probability defined by the corresponding element in the
second vector (whose elements are automatically renormalised to sum to 1);
* if it is of the fourth form, the first argument of WithoutReplacement is
sampled n times without replacement. So the list of parameters ends up being
longer than the original list of parameter sets.
Here is an example of a list of parameter sets:
ParameterSets["expand and simplify"] =
{{Integer,{2,5}},
{Integer,{2,5}},
{{x,y,z,p,q,r}},
{{-5,-4,-3,-2,-1,1,2,3,4,5}},
{{a,b,c,1},
{1,1,1,3}},
{{-5,-4,-3,-2,-1,1,2,3,4,5}},
{{-5,-4,-3,-2,-1, 0,1,2,3,4,5},
{ 1, 1, 1, 1, 1,15,1,1,1,1,1}}
};
(iv) The random sampling of the parameter sets outputs a one-dimensional list
of parameters, the position of each of which corresponds to that of the set
from which it was drawn. What GiveQuestion ultimately requires, though, is
another list: the set of insertions which, together with the question template,
go to make up a particular question. The process by which the parameter list is
converted into the insertion list must be defined by the question function.
The question function takes as its argument set the elements of the parameter
list, in order. It outputs a list, whose elements will then be inserted, in
order, into the question template.
For example:
QuestionFunction["expand and simplify"][a_,b_,c_,d_,e_,f_,g_] :=
{ a(b c + d e) + f c + g e };
Note that, although the output must be a list, the input is not. Question
function definitions which begin like this will not work:
QuestionFunction["expand and simplify"][ {a_,b_,c_,d_,e_,f_,g_} ] :=
For maximum efficiency, the question function can be implemented as a pure
function. This is how the "expand and simplify" example really reads:
QuestionFunction["expand and simplify"] =
{ #1(#2 #3 + #4 #5) + #6 #3 + #7 #5 }&;
(v) The way the answer function works is exactly similar, for example:
AnswerFunction["expand and simplify"]=
{ Expand[#1(#2 #3 + #4 #5) + #6 #3 + #7 #5] }&;
----
The METRIC Project - 26 June 1996.