From bb511f30d607d8ea86bc0d541f8e26b524a86f4d Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Fri, 22 Nov 2019 19:43:09 +1100 Subject: [PATCH] MDL-67151 core_question: Support scientific format at question preview --- lib/questionlib.php | 2 +- question/tests/behat/preview_question.feature | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/questionlib.php b/lib/questionlib.php index 7aee57fb94e..8566321a1e1 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -806,7 +806,7 @@ function question_preview_url($questionid, $preferredbehaviour = null, } if (!is_null($maxmark)) { - $params['maxmark'] = format_float($maxmark, strlen($maxmark), true, true); + $params['maxmark'] = format_float($maxmark, -1); } if (!is_null($displayoptions)) { diff --git a/question/tests/behat/preview_question.feature b/question/tests/behat/preview_question.feature index cba500906f5..e3630e34a39 100644 --- a/question/tests/behat/preview_question.feature +++ b/question/tests/behat/preview_question.feature @@ -1,4 +1,4 @@ -@core @core_question +@core @core_question @javascript @_switch_window Feature: A teacher can preview questions in the question bank In order to ensure the questions are properly created As a teacher @@ -26,7 +26,6 @@ Feature: A teacher can preview questions in the question bank When I choose "Preview" action for "Test question to be previewed" in the question bank And I switch to "questionpreview" window - @javascript @_switch_window Scenario: Question preview shows the question and other information Then the state of "What is pi to two d.p.?" question is shown as "Not yet answered" And I should see "Marked out of 1.00" @@ -34,19 +33,16 @@ Feature: A teacher can preview questions in the question bank And I should see "Attempt options" And I should see "Display options" - @javascript @_switch_window Scenario: Preview lets the teacher see what happens when an answer is saved When I set the field "Answer:" to "1" And I press "Save" Then the state of "What is pi to two d.p.?" question is shown as "Answer saved" - @javascript @_switch_window Scenario: Preview lets the teacher see what happens when an answer is submitted When I set the field "Answer:" to "3.14" And I press "Submit and finish" Then the state of "What is pi to two d.p.?" question is shown as "Correct" - @javascript @_switch_window Scenario: Preview lets the teacher see what happens with different review options Given I set the field "Answer:" to "3.14" And I press "Submit and finish" @@ -56,7 +52,6 @@ Feature: A teacher can preview questions in the question bank Then the state of "What is pi to two d.p.?" question is shown as "Complete" And I should see "1.00000" - @javascript @_switch_window Scenario: Preview lets the teacher see what happens with different behaviours When I set the field "How questions behave" to "Immediate feedback" And I set the field "Marked out of" to "3" @@ -67,18 +62,20 @@ Feature: A teacher can preview questions in the question bank And I should see "Mark 0.00 out of 3.00" And I should see "Not accurate enough." - @javascript @_switch_window Scenario: Preview lets the teacher "Start again" while previewing Given I set the field "Answer:" to "1" And I press "Submit and finish" When I press "Start again" Then the state of "What is pi to two d.p.?" question is shown as "Not yet answered" - @javascript @_switch_window Scenario: Preview lets the teacher "Fill in correct response" while previewing When I press "Fill in correct responses" Then the field "Answer:" matches value "3.14" - @javascript @_switch_window Scenario: Preview has an option to export the individual quesiton. Then following "Download this question in Moodle XML format" should download between "1000" and "2500" bytes + + Scenario: Preview a question with very small grade + When I set the field "Marked out of" to "0.00000123456789" + And I press "Start again with these options" + Then the field "Marked out of" matches value "0.00000123456789"