Variable numeric

Question types ::: qtype_varnumeric
Maintained by TimTim Hunt, at the OU (Perry building)Mahmoud Kassaei
Part of set Open University.
A calculated numeric question type with variable and expression evaluation. Random values are generated for each student attempting the quiz.
Latest release:
663 sites
25 fans
Current versions available: 8

There are working examples in eAssessment with Moodle on our OpenLearn site.

The documentation is in How to create questions in Moodle on that site.


Screenshot #0
Screenshot #1


Tim Hunt (Lead maintainer)
at the OU (Perry building)
Mahmoud Kassaei: Developer
Jamie Pratt: Developer
Phil Butcher: Question type designer
Colin Chambers: Developer
Chris Nelson: Product owner
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Andreu Martí
    Thu, Apr 23, 2020, 7:23 PM
    I'd also like to know this, because like other languages in spanish and in catalan the coma is the decimal separator. In moodle core, the numerical question has it resolved. Does anybody know how to fix this? thank you in advance.
  • Tim
    Thu, Jun 11, 2020, 5:37 AM
    Latest version works with Moodle 3.9.
  • Mohammed Setiha
    Thu, Sep 24, 2020, 9:16 PM
    I need to rand float !!!
  • Tim
    Thu, Sep 24, 2020, 10:00 PM
    rand_int(0, 10000)/10000
  • Eva Koperdakova
    Fri, Aug 19, 2022, 4:32 PM
    Hello, It says "Release 2.0 for Moodle 3.11+
    Moodle 3.9, 3.10, 3.11, 4.0", but no success updating on 3.9 latest today Aug 19th 2022.
    It requires 3.11 at least.
  • Tim
    Fri, Aug 19, 2022, 5:11 PM
    I'm sorry. You are right, it should be 3.11+. I have updated the information in this plugins DB entry. Thank you for pionting out the error.
  • Simon CHARBIT
    Wed, Mar 15, 2023, 6:35 PM
    Thank you very much for this plugin, I use it a lot. I am a French physics teacher.
    I would very much like to be able to generate graphs using the random data from the questions.
    Do you know if there is a way to do something like this?
  • Chris Nelson
    Wed, Mar 15, 2023, 7:09 PM
    @ Simon, I'm not aware of being able to in this quiz question, but you can in STACK (
  • Simon CHARBIT
    Tue, Jun 20, 2023, 3:39 PM
    Hello, i try to go from Moodle 3.8 to moodle 4.0
    I use a lot this type of question and most of them are ok but some of them are corrupt (i dont know why and i cant open them correct something.

    here the code of error :

    line 372 of /question/type/varnumericset/questionbase.php: DivisionByZeroError thrown
    line 412 of /question/type/varnumericset/questionbase.php: call to qtype_varnumeric_question_base::round_to()
    line 272 of /question/type/varnumericset/questionbase.php: call to qtype_varnumeric_question_base::has_too_many_sig_figs()
    line 212 of /question/type/varnumericset/questionbase.php: call to qtype_varnumeric_question_base->compare_num_as_string_with_answer()
    line 145 of /question/type/varnumericset/questionbase.php: call to qtype_varnumeric_question_base->compare_response_with_answer()
    line 558 of /question/type/varnumericset/questionbase.php: call to qtype_varnumeric_question_base->get_matching_answer()
    line 331 of /question/behaviour/behaviourbase.php: call to qtype_varnumeric_question_base->classify_response()
    line 1582 of /question/engine/questionattempt.php: call to question_behaviour->classify_response()
    line 132 of /question/classes/statistics/responses/analyser.php: call to question_attempt->classify_response()
    line 753 of /mod/quiz/report/statistics/report.php: call to core_question\statistics\responses\analyser->calculate()
    line 722 of /mod/quiz/report/statistics/report.php: call to quiz_statistics_report->analyse_responses_for_questions()
    line 675 of /mod/quiz/report/statistics/report.php: call to quiz_statistics_report->analyse_responses_for_all_questions_and_subquestions()
    line 950 of /mod/quiz/report/statistics/report.php: call to quiz_statistics_report->get_all_stats_and_analysis()
    line 2492 of /mod/quiz/lib.php: call to quiz_statistics_report->calculate_questions_stats_for_question_bank()
    line 8053 of /lib/moodlelib.php: call to mod_quiz_calculate_question_stats()
    line 140 of /question/classes/local/statistics/statistics_bulk_loader.php: call to component_callback()
    line 56 of /question/classes/local/statistics/statistics_bulk_loader.php: call to core_question\local\statistics\statistics_bulk_loader::load_statistics_for_place()
    line 1037 of /question/classes/local/bank/view.php: call to core_question\local\statistics\statistics_bulk_loader::load_aggregate_statistics()
    line 984 of /question/classes/local/bank/view.php: call to core_question\local\bank\view->load_required_statistics()
    line 768 of /question/classes/local/bank/view.php: call to core_question\local\bank\view->display_question_list()
    line 59 of /question/edit.php: call to core_question\local\bank\view->display()
  • Tim
    Tue, Jun 20, 2023, 4:16 PM
    I suspect that error is not caused by any chagnes in Moodle or this plugin.

    More likely, as part of upgrading everything else, you have also upgraded to PHP 8.0 or 8.1, and that error looks like the type of thing that now causes problems in recent PHP versions.

    Anyway, it is a problem and it needs to be fixed. (Odd that you can get to a divide by zero in the round_to code.) Please can you describe one of the quetions which is broken (or export it as XML, and send it to us to look at. Thanks.
  • Simon CHARBIT
    Fri, Jun 23, 2023, 5:57 PM
    I was not capable of identifying which question was guilty.
    When I import the same question from a backup, it was working...
    I can send you the questions which were in the category (7 questions) but I can’t post them here.
    I imagine the problem could be because one of the questions has a really small result like 1x10^-30
    I already have some trouble with some questions which are given some results which was really low like 1x10-50 but it was not the same problem Moodle was not good to say if the answer was good or not he did not prevent me from accessing the question bank.
    Thank you very much
  • Bruce Currell
    Sat, Sep 2, 2023, 7:17 AM
    Are there any issues with this plug-in in the newest version of moodle 4.2.2 ? (no mentions of 4.1, 4.2 in description)

    2.0 for Moodle 3.11+ (2022042500)
    Moodle 3.11, 4.0
    Released: Thursday, 5 May 2022, 1:00 PM

    This plug-in I use HUGELY in my physics courses.
  • Simon CHARBIT
    Sat, Oct 28, 2023, 9:47 PM
    I am agree with Bruce i use a lot this plug-in in my physics courses and i am waiting a version who are stable on moodle 4.2 or 3 before updating moodle smile
  • Simon CHARBIT
    Sun, Mar 24, 2024, 12:27 AM
    Hello, I used this plugin a lot to create a lot of questions
    I started using Stack this year and I use it less and less, but I clearly don't have the courage to move all my numeric variable questions to Stack (more than two thousand questions...)

    I have two questions regarding the future of this plugin:

    I have the impression that there are no more updates, do you plan to continue to upgrade it to future versions of Moodle?

    Stack recently made it possible to choose the decimal separator in the answer choice (. or , )
    I really want to ensure that all my questions use the same decimal separator (this would make life easier for my students).

    Do you think it is possible to do the same thing for this plugin?

    Thank you so much,
  • Tim
    Mon, Mar 25, 2024, 5:55 PM
    We still use and maintain this plugin. What keeps not getting done because we are too busy is updating the copy of the code on github and publishing here. This is bad, but there are so many hours in a day.

    Decimal separators are a surprisingly difficult problem. We currently have no plans to support different ones.
1 2 3
Please login to post comments