Calculated questions

Calculated questions

by roberto liberatore -
Number of replies: 10
I am using extensively the quiz module to prepare questions for students, in particular I found calculated question very useful, especially for the capability to create the same question with different datasets. The only limit I found is that, even if you can set up more than one answer, the available field to answer a question is only one.
In fact the problems I have to set up consist, for a given dataset of parameters, in calculating some other parameters; the student should input the answers in appropriate blank fields available in the question itself. But in the actual version of calculated questions, seem to me, I can ask to calculate only one parameter. Is that true or I am doing some mistake? If I am right, is on going any improvement in that sense?


Average of ratings: -
In reply to roberto liberatore

Re: Calculated questions

by Pierre Pichet -
There is a project that should be completed in some weeks from now, that will allow more than one answer in each question with the same datasets and also allow to create either a standard calculated question or a multichoice calculated question.
See http://moodle.org/mod/forum/discuss.php?d=74021

Pierre

P.S.The work is postponed a little as I am also working on the multianswer (cloze) type. I want to create a code that will be usefull for 'all' multianswer type questions.

In reply to Pierre Pichet

Re: Calculated questions

by roberto liberatore -
Great. This is right the quiz structure I had in mind, allowing maximum flexibility to create question. Thanks a lot.
In reply to Pierre Pichet

Re: Calculated questions

by Bernd Greifluss -
I am a bit confused: I see that this project you are talking about is the "Calculated multiquestions proposal", right? It seems to be exactly what I need, too. But: Is this functionality available today? Thanks a lot in advance!
In reply to Bernd Greifluss

Re: Calculated questions

by Pierre Pichet -
I am always optimistic about the delaysshy.
Not now but something in a near future like january...

Pierre
P.S. This is a complex thing to set and this is why I am working now on improving multianswer (Cloze) coding.
In reply to Pierre Pichet

Re: Calculated questions

by Bernd Greifluss -

Hi Pierre,

I am afraid, I can't wait that long (and especially longer). Therefore, I was wondering, if it is possible to change some code, write a plugin, whatever ... in order to force moodle to reuse the individual values of shared wild cards within one category for each student. That's actually all I need!

I will try again to explain a bit more in detail to make things clear: Currently, it is possible to share wildcards within one category in such a way that each occurance of a wildcard variable (in different questions) accesses the same random item set for that wildcard variable but, however, it chooses for each question a random value from that set. I simply want to make moodle to use only one item of that random item set for each quiz taker for each wildcard variable in all questions in a category. Hope it's clear?!?

Do you think this approach is feasable?

Cheers

Bernd

In reply to Bernd Greifluss

Re: Calculated questions

by Pierre Pichet -
The only way to do this would is to use a multianswer calculated question.
Are you using this for a small moodle installation i.e. one course or a large installation?
Are you using thiseas part of the grading process or as an exercise?
And which moodle version ?
At a small scale I could furnish you an experimental version of the project.

Pierre

In reply to Bernd Greifluss

Re: Calculated questions

by Pierre Pichet -
Here is a solution
You put somewhere in the introduction text of the quiz the expression 'synchronize_calculated' and your calculated questions will use the same data number.
You need to modify the question/type/calculated/questiontype.php part that is bold, not all the function because the database calls are specific to 2.0

function create_session_and_responses(&$question, &$state, $cmoptions, $attempt) {
// Find out how many datasets are available
global $CFG, $DB;
if(!$maxnumber = (int)$DB->get_field_sql(
"SELECT MIN(a.itemcount)
FROM {question_dataset_definitions} a,
{question_datasets} b
WHERE b.question = ?
AND a.id = b.datasetdefinition", array($question->id))) {
print_error('cannotgetdsforquestion', 'question', '', $question->id);
}

// Choose a random dataset
if (!isset($cmoptions->intro) || strstr($cmoptions->intro, 'synchronize_calculated') === false ) {
$state->options->datasetitem = rand(1, $maxnumber);
}else{
if( !isset($cmoptions->synchronize_calculated)) {
$state->options->datasetitem = rand(1, $maxnumber);
$cmoptions->synchronize_calculated = $state->options->datasetitem ;
}else {
if ($cmoptions->synchronize_calculated <= $maxnumber){
$state->options->datasetitem = $cmoptions->synchronize_calculated ;
}else {
$state->options->datasetitem = rand(1, $maxnumber);
}
}
};
$state->options->dataset =
$this->pick_question_dataset($question,$state->options->datasetitem);
$state->responses = array('' => '');
return true;
}

You should create the same number of items for each datasets.
Also note that the number used is applied to all datasets private or category.
I think I will use this feature so thanks for the cue.

Pierre



In reply to Bernd Greifluss

Re: Calculated questions

by Pierre Pichet -
See MDL-17278 which is an answer to your request.

Pierre
In reply to Pierre Pichet

Re: Calculated questions

by Bernd Greifluss -

Great, works perfectly so far...

For everyone who is interested and does not use Moodle 2.0 yet, but for example release 1.9.3 (like I do) here is the corresponding howto. Note however, that this approach permanently synchronizes variables, i.e. it is not necessary to put the text 'synchronize_calculated' in the intro field of the quiz:

Simply replace line 44 in "moodle\question\type\datasetdependent\abstractqtype.php" with the following code:

if( !isset($cmoptions->synchronize_calculated)) {
   $state->options->datasetitem = rand(1, $maxnumber);
   $cmoptions->synchronize_calculated = $state->options->datasetitem ;
  }else {
   if ($cmoptions->synchronize_calculated <= $maxnumber){
    $state->options->datasetitem = $cmoptions->synchronize_calculated ;
   }else {
    $state->options->datasetitem = rand(1, $maxnumber);
   }
  };

Cheers, 
Bernd

In reply to Bernd Greifluss

Re: Calculated questions

by Pierre Pichet -
The more flexible solution MDL_17278 should be availabel soon

Pierre