Note: You are currently viewing documentation for Moodle 2.4. Up-to-date documentation for the latest stable version of Moodle may be available here: Question Engine 2:Numerical formats.

Development:Question Engine 2:Numerical formats

From MoodleDocs
Revision as of 23:39, 30 April 2011 by Pierre Pichet (talk | contribs) (Created page with "The Question Engine 2 structure allows implementation of new features for numerical question types ( numerical and calculated). This page describes a possible implementation and ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The Question Engine 2 structure allows implementation of new features for numerical question types ( numerical and calculated). This page describes a possible implementation and its rationale.

The text should be readed as a personal summary of the work in progress and not as a textbook on computer language and real numbers representation.

It is related to the forum discussion


Numbers as written by human and readed by computer language

The main feature of numerical question type is to ask the student to give a numerical answer i.e. a number. Most often this means a numerical value that is not an integer ( dates are a current example of integer value response) but a real number which value is expressed most often as a decimal number i.e 1.234 .

Computer languages ( i.e PHP used in Moodle) store real numbers in a different way than human do (decimal part and exponent similar to 1.234 E00) and humans do not expressed real nmumbers in an universal format.

The separator between the unit and the decimal fraction is often either a . or a ,  
1.234   1,234

Furthermore to help reading large numbers, most language add another separator for thousands often space or , if it is not used already as unit separator.

123 456.78     123,456.78   123 456,78 

PHP as a computer language use space to separate the language components so cannot use space as a thousand separator.

, is also used to separate variables so PHP use a simpler syntax 123456.78.

As this is stored in the computer as 2 parts 1.2345678+E05 will be a structure that is well recognized by computer language as PHP.

Pierre Pichet 07:39, 1 May 2011 (WST)