Moodle 2.4+, calculated questions & integer values for wildcards

Moodle 2.4+, calculated questions & integer values for wildcards

by Hiram Bollaert -
Number of replies: 11

Each time I present Moodle a range of values for a wildcard using 0 decimals, Moodle returns numbers with 1 decimal when I generate a dataset.

Try it:

Question text: Give {integer}

Correct formula: {integer} (tolerance is 0 nominal, show 0 decimals)

Wild card {integer}: will use the same existing private dataset... & do not synchronize

add item: => specify whole numbers 1 to 10, 0 decimals(uniform)

click: update the answers tolerance parameters

click any of the add item options

=> you'll see an error and no new item is added.

 

Already reported somewhere? Anyone find the same error? Did I do something wrong?
Cheers
Hiram - uses 'floor' or 'round' as a work around solution

 

Average of ratings: -
In reply to Hiram Bollaert

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by Pierre Pichet -

Hi Hiram,

This is a known bug ( MDL-31680) related to way sprintf function handle numbers with decimal .0 . The correction was applied only to master.

Pierre

P.S. There are also other problems with the datasetitems_form which are on my todo list...

In reply to Pierre Pichet

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by Hiram Bollaert -

Hey Pierre

although mdl-31680 is closed, the error still exists in moodle2.5.2+ (Build: 20131004)...?

Which other problems in datasetitems did you encounter?

cheers
Hiram

In reply to Hiram Bollaert

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by Pierre Pichet -

Hi Hiram,

Effectively MDL-31680 is closed but the solution has only been put in actual master and will be available in november as 2.6 version.

The interface does not work correctly as it does not remember well all the options set when you do operations as generate new values.

Pierre

In reply to Pierre Pichet

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by jay lopez -
Hi Pierre,
I was wondering if wildcards should be able to accept negative integers as well or is it designed to to generate positive numbers only. When parameters is set to negative values (eg -1 to -10) w/ 0 decimals - the generated values contain only positive values (1 to 10) and contains decimals as what Hiram pointed out. Is this also fixed in 2.6?
In reply to jay lopez

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by Pierre Pichet -

Yes this can be done however when you put -1 in the left case and 10 in the rigth one taking for granted that the - between the two input field is a negative sign then this won't work as you intuitively think.

The 10 will be interpreted as +10 so you will generate numbers that can be positive.

The - between the two input fields should be replaced by something as to .

I just put a note in MDL-37744 about this.

Even  -10 to -1 will work.

Pierre

In reply to Pierre Pichet

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by jay lopez -

Actually, I set -10 to -1 as parameters. If it should work, then I probably did something wrong. I'll try again and see if I get the desired results this time.

Thank you. Good day!

In reply to Pierre Pichet

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by jay lopez -

I thought I made a mistake because I can't replicate the problem I described earlier. However, I realized just now how that the problem occured when I edit a simple calculated question today. This is what I did:

  • The initial question has two wild cards (say "a" and "b")
  • I then edit the question
  • I change the wild card "b" to "c" in the question and the answer formula
  • I click on Find the wild cards{x..}...
  • I changed parameters of "c" (range 1to10; 0 decimal places)
  • parameters of "a" is again set to its original values (range -1 to -10; 0 decimal places)
  • I generate 20 wildcards display 20
  • When I look at the new generated values - this is what happened:
  1. generated values of "a" is positive although range is -1 to -10
  2. generated values of c has 1 decimal places although it is set to 0 decimal places
The solution is that I make a new simple calc question rather than edit it to be saved as another question. This unfortunately is more time consuming.

Thank you for your feedback.
In reply to jay lopez

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by Pierre Pichet -

On a closer look, it seems that the generator parameters are not saved and retrieved correctly .

I created a new bug MDL-45915 as a subtask of MDL-37744.

Pierre

In reply to Pierre Pichet

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by jay lopez -

Thank you very much.

In reply to Pierre Pichet

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by jay lopez -

Hi Pierre,

I was following bug MDL-45915 and I saw your comment about the generator restarting with the default values. I would like to note that just like what you said in the tracker - I noticed that the generator reset the values to "default" when I tried editing the parameters.  However what I really find faulty is the fact that even though I changed the defaulted parameters for the generator, It seems to generate values not in the range of my new parameters. My hunch is that the generator is not accepting the new parameters I set and instead is using the "defaulted parameter" - this despite the fact that the display seems to indicate that the new parameters was set correctly. Hope this helps in some way.

Jay

In reply to jay lopez

Re: Moodle 2.4+, calculated questions & integer values for wildcards

by Pierre Pichet -

Thanks,

There are some other  problems that interfere when you try to isolate this particular problem.

This is why I set this as a subtask of a more comprehensive revision of the dataitems generation.

Pierre