Skip to content

Commit

Permalink
improve language
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippImhof committed Dec 23, 2024
1 parent 15bdf00 commit 86e4c95
Show file tree
Hide file tree
Showing 12 changed files with 421 additions and 427 deletions.
5 changes: 0 additions & 5 deletions classes/local/evaluator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
use qtype_formulas;
use Throwable, Exception;

// TODO: calculate_algebraic_diff etc. should probably not use known variables and thus
// not allow using builtin functions as variables, because students do not have access to the
// prefix operator; in any case it needs to be clearly documented


/**
* Evaluator for qtype_formulas
*
Expand Down
269 changes: 134 additions & 135 deletions lang/en/qtype_formulas.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/behat/criterion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Feature: Test setting the grading criterion in different modes
| correctness_simple_tol[0] | 1 |
And I press "id_updatebutton"
And I wait until the page is ready
Then I should see "relative error (_relerr) cannot be used with answer type algebraic formula"
Then I should see "Relative error (_relerr) cannot be used with answer type algebraic formula."
And the following fields match these values:
| correctness_simple_mode[0] | 0 |

Expand All @@ -76,7 +76,7 @@ Feature: Test setting the grading criterion in different modes
When I set the field "Grading criterion*" to "a"
And I press "id_submitbutton"
And I wait until the page is ready
Then I should see "unknown variable: a"
Then I should see "Unknown variable: a"
And the following fields match these values:
| correctness_simple_mode[0] | |
And the "Simplified mode" "checkbox" should be disabled
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ Feature: Test editing a Formulas question
And I set the following fields to these values:
| Grading variables | test = 1/0; |
And I press "id_submitbutton"
Then I should see "division by zero is not defined"
Then I should see "Division by zero is not defined."
And I set the following fields to these values:
| Grading variables | test = 2; |
And I press "id_submitbutton"
Then I should not see "division by zero is not defined"
Then I should not see "Division by zero is not defined."
30 changes: 15 additions & 15 deletions tests/behat/editquickvalidation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,64 +26,64 @@ Feature: Test on-the-fly validation of variables while editing a question
When I follow "Variables"
And I set the field "Random variables" to "a=+"
And I take focus off "id_varsrandom" "field"
Then I should see "1:3:syntax error: unexpected end of expression after '+'"
Then I should see "1:3:Syntax error: unexpected end of expression after '+'."
And I set the field "Random variables" to "a={1,2,3};"
And I take focus off "id_varsrandom" "field"
Then I should not see "1:3:syntax error: unexpected end of expression after '+'"
Then I should not see "1:3:Syntax error: unexpected end of expression after '+'."

Scenario: Validate global variables
When I follow "Variables"
And I set the field "Global variables" to "a=+"
And I take focus off "id_varsglobal" "field"
Then I should see "1:3:syntax error: unexpected end of expression after '+'"
Then I should see "1:3:Syntax error: unexpected end of expression after '+'."
And I set the field "Global variables" to "a=5;"
And I take focus off "id_varsglobal" "field"
Then I should not see "1:3:syntax error: unexpected end of expression after '+'"
Then I should not see "1:3:Syntax error: unexpected end of expression after '+'."
And I set the field "Global variables" to "a=2*b"
And I take focus off "id_varsglobal" "field"
Then I should see "1:5:unknown variable: b"
Then I should see "1:5:Unknown variable: b"
And I set the following fields to these values:
| id_varsrandom | b={1,2,3}; |
| id_varsglobal | |
And I set the field "Global variables" to "a=2*b"
And I take focus off "id_varsglobal" "field"
Then I should not see "1:5:unknown variable: b"
Then I should not see "1:5:Unknown variable: b"

Scenario: Validate global variables with prior error in random variables
When I follow "Variables"
And I set the following fields to these values:
| id_varsglobal | b=1 |
| id_varsrandom | a=+ |
And I click on "id_varsglobal" "field"
Then I should see "1:3:syntax error: unexpected end of expression after '+'" in the "#id_error_varsrandom" "css_element"
Then I should see "1:3:Syntax error: unexpected end of expression after '+'." in the "#id_error_varsrandom" "css_element"
And the focused element is "id_varsrandom" "field"

Scenario: Validate local variables
When I follow "Part 1"
And I follow "Show more..."
And I set the field "Local variables" to "a=+"
And I take focus off "id_vars1_0" "field"
Then I should see "1:3:syntax error: unexpected end of expression after '+'"
Then I should see "1:3:Syntax error: unexpected end of expression after '+'."
When I set the field "Local variables" to "a=5;"
And I take focus off "id_vars1_0" "field"
Then I should not see "1:3:syntax error: unexpected end of expression after '+'"
Then I should not see "1:3:Syntax error: unexpected end of expression after '+'."
When I set the field "Local variables" to "a=2*b"
And I take focus off "id_vars1_0" "field"
Then I should see "1:5:unknown variable: b"
Then I should see "1:5:Unknown variable: b"
When I set the following fields to these values:
| id_varsrandom | b={1,2,3}; |
And I set the field "Local variables" to "a=2*b"
And I take focus off "id_vars1_0" "field"
Then I should not see "1:5:unknown variable: b"
Then I should not see "1:5:Unknown variable: b"
When I set the field "Local variables" to "a=2*c"
And I take focus off "id_vars1_0" "field"
Then I should see "1:5:unknown variable: c"
Then I should see "1:5:Unknown variable: c"
When I set the following fields to these values:
| id_varsrandom | b={1,2,3}; |
| id_varsglobal | c=4; |
| id_vars1_0 | a=2*c; |
And I take focus off "id_vars1_0" "field"
Then I should not see "1:5:unknown variable: c"
Then I should not see "1:5:Unknown variable: c"

Scenario: Validate local variables with prior error in random or global variables
When I follow "Variables"
Expand All @@ -93,15 +93,15 @@ Feature: Test on-the-fly validation of variables while editing a question
And I take focus off "id_varsrandom" "field"
And I set the field "id_vars1_0" to "a=2*c;"
And I take focus off "id_vars1_0" "field"
Then I should see "1:3:syntax error: unexpected end of expression after '+'" in the "#id_error_varsrandom" "css_element"
Then I should see "1:3:Syntax error: unexpected end of expression after '+'." in the "#id_error_varsrandom" "css_element"
And the focused element is "id_varsrandom" "field"
When I set the following fields to these values:
| id_varsrandom | a={1,2} |
| id_varsglobal | b=++ |
And I take focus off "id_varsglobal" "field"
And I set the field "id_vars1_0" to "c=3*a;"
And I take focus off "id_vars1_0" "field"
Then I should see "1:4:syntax error: unexpected end of expression after '+'" in the "#id_error_varsglobal" "css_element"
Then I should see "1:4:Syntax error: unexpected end of expression after '+'." in the "#id_error_varsglobal" "css_element"
And the focused element is "id_varsglobal" "field"
# Last two steps verify that the field does not take back the focus, if it already had en error.
And I click on "id_varsrandom" "field"
Expand Down
Loading

0 comments on commit 86e4c95

Please sign in to comment.