Increasing the number of data sets for calculated question type

Increasing the number of data sets for calculated question type

by H Singh -
Number of replies: 6

Hello:

I am shortly going to start teaching a class of strength 500 (yeah, I know).

For the question type that is going to be used most often (calculated question type with feedback - feedback behaviour type developed graciously by Tim Hunt), I find that I am limited to 100 data sets for the wildcards.

I would like to increase that number, perhaps to 400 (ideally 500) or so, so that the random chance of any two students getting the same data set of values be small (or ideally, non-existent). Is there a Moodle configuration parameter that controls this, or is this hardcoded as a number that an admin/instructor cannot change?

If the former, how do I change this?

Thanks.

Average of ratings: -
In reply to H Singh

Re: Increasing the number of data sets for calculated question type

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I don't use the calculated question type much, so I always forget how it is supposed to work. Is it no possible to first generate 100 dataset items, and then generate another 100, to get to 200?

If not then you will need to alter the code. I think the bit to change is in question/type/calculated/datasetitems_form.php https://github.com/moodle/moodle/blob/master/question/type/calculated/datasetitems_form.php#L218

The number 100, appears twice there, and you should be able to change it.

In reply to Tim Hunt

Re: Increasing the number of data sets for calculated question type

by H Singh -

I tested it out in practice.

No, it is not a 100 at a time. It is 100 period.

Is there possibility to define this more flexibly? Hardcoding (as an ex-programmer) a number like that (which appears in the UI as a choice to the user) appears to be bad practice smile Just saying.

I will have our admin take a look at the github link.

In reply to H Singh

Re: Increasing the number of data sets for calculated question type

by Pierre Pichet -

Although const MAX_DATASET_ITEMS = 100; is defined in the class qtype_calculated extends question_type code it was not used in all the question type code as there was no real demand for creating  so much questions in these old times where terabites where futuristic and student groups where smaller....

There is no real difficulties to change that limit after having change all the occurences of 100 in the code including import and export although some of the interfaces like the display of the 500 values when there is an error or you want to modify yourself the values, will need some reworking.

One way to use the actual code is to create in a new category a first 100 items calculated (either regular, simple,multichoice).

Then create a second one as a copy and edit this copy to generate a new set of data.

You can create as much variants as you need and add them in the quiz as a random question.

In reply to Pierre Pichet

Re: Increasing the number of data sets for calculated question type

by Pierre Pichet -

In a first rapid survey

MAX_DATASET_ITEMS
seem to be used correctly in calculated/questiontype.php
no used neither 100 in calculated/question.php , datasetdefinitions_form.php
but used to display in datasetitems_form.php

$addremoveoptions = array();
        $addremoveoptions['1']='1';
        for ($i=10; $i<=100; $i+=10) {
             $addremoveoptions["{$i}"] = "{$i}";
        }
        $showoptions = Array();
        $showoptions['1']='1';
        $showoptions['2']='2';
        $showoptions['5']='5';
        for ($i=10; $i<=100; $i+=10) {
             $showoptions["{$i}"] = "{$i}";
        }
no problems on import /format/xml/format.php
public function import_calculated($question) {
and most probably on export
              // The tag $question->export_process has been set so we get all the
                // data items in the database from the function
                // qtype_calculated::get_question_options calculatedsimple defaults
                // to calculated.

In reply to Pierre Pichet

Re: Increasing the number of data sets for calculated question type

by Pierre Pichet -

I just  created MDL-51134 Increasing the dataset items max in calculated question type so that if somebody want to proceed further.

I could not solve it before this fall (for northen hemisphere) session.


In reply to Pierre Pichet

Re: Increasing the number of data sets for calculated question type

by H Singh -

Thanks for doing that. Added a comment as well.