Skip to content
Snippets Groups Projects
Commit 8daabe65 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Fix to issue #1059: test case construction and decimal separators.

parent 9d9330df
Branches
No related tags found
No related merge requests found
......@@ -94,10 +94,13 @@ For the checkbox type you will need the whole list.
tc1:mcq_correct(ta);
### Test case construction and numerical precision.
### Test case construction and numerical precision
You can construct test cases using the functions such as `dispdp` to create a test-case input with trailing zeros. This is neeeded if the input, or answer test, is testing for a minimum number of decimal places or significant figures.
### Test case construction and decimal separators
The decimal separator option (e.g. `.` or `,`) is a very thin layer based on the student input. The teacher must always use a `.` (full stop) as the decimal separator in question variables. Consistent with this, all test-case construction must use a `.` (full stop) as the decimal separator. This means it's hard to test the functionality of the decimal separator option (sorry), but otherwise there is genuine confusion in the internal logic about _when_ to assume a `,` is a decimal separator or a list separator. Also, if you change this option in the question you do not need to change all your test cases.
## Testing values of variables
......
......@@ -39,6 +39,8 @@ $confirmthistestcase = optional_param('confirmthistestcase', null, PARAM_INT);
// Load the necessary data.
$questiondata = $DB->get_record('question', array('id' => $questionid), '*', MUST_EXIST);
$question = question_bank::load_question($questionid);
// We hard-wire decimals to be a full stop when testing questions.
$question->options->set_option('decimals', '.');
if ($testcase || $confirmthistestcase) {
$qtest = question_bank::get_qtype('stack')->load_question_test($questionid, $testcase);
}
......@@ -71,7 +73,6 @@ if (!is_null($seed)) {
$slot = $quba->add_question($question, $question->defaultmark);
$quba->start_question($slot);
// Initialise $PAGE.
$backurl = new moodle_url('/question/type/stack/questiontestrun.php', $urlparams);
if (!is_null($testcase)) {
......@@ -125,7 +126,6 @@ if ($mform->is_cancelled()) {
$inputs[$name] = $value;
}
$qtest = new stack_question_test($qtest->description, $inputs);
$response = stack_question_test::compute_response($question, $inputs);
foreach ($question->prts as $prtname => $prt) {
......
......@@ -68,6 +68,8 @@ if (!$questiondata) {
throw new stack_exception('questiondoesnotexist');
}
$question = question_bank::load_question($questionid);
// We hard-wire decimals to be a full stop when testing questions.
$question->options->set_option('decimals', '.');
// Process any other URL parameters, and do require_login.
list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($question);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment