Skip to content

Commit

Permalink
fix to issue #1359: add Dioptre as extra units.
Browse files Browse the repository at this point in the history
  • Loading branch information
sangwinc committed Jan 16, 2025
1 parent d224f5c commit bc32e2b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions stack/cas/casstring.units.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ class stack_cas_casstring_units {
['yd', '36*in', 'yd', 'yard'],
['mi', '5280*12*in', 'mi', 'mile'],
['lb', '4.4482*N', 'lb', 'pound'],
['dpt', '1/m', 'dpt', 'Dioptre'],
];

/**
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/answertestfixtures.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2484,6 +2484,7 @@ class stack_answertest_test_data {
['Units', '1', '0.0*km/s', '0.0*m/s', 1, 'ATUnits_compatible_units m/s.', ''],
['Units', '1', '0.0*m', '0.0*m/s', 0, 'ATUnits_incompatible_units. ATUnits_correct_numerical.', ''],
['Units', '1', '0.0', '0.0*m/s', 0, 'ATUnits_SA_no_units.', ''],
['Units', '3', '0.200*dpt', '0.200/m', 1, 'ATUnits_compatible_units 1/m.', ''],
['Units', '1', '7*in', '7*in', 1, 'ATUnits_units_match.', 'Imperial'],
['Units', '1', '6*in', '0.5*ft', 1, 'ATUnits_compatible_units in.', ''],
['Units', '4', '2640*ft', '0.5*mi', 1, 'ATNumSigFigs_WithinRange. ATUnits_compatible_units in.', ''],
Expand Down
13 changes: 13 additions & 0 deletions tests/input_units_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -1327,4 +1327,17 @@ public function test_validate_student_response_complex_1(): void {
$state->contentsdisplayed);
$this->assertEquals('', $state->errors);
}

public function test_validate_student_response_dpt(): void {
$options = new stack_options();
$el = stack_input_factory::make('units', 'sans1', '0.520*dpt');
$el->set_parameter('insertStars', 1);
$state = $el->validate_student_response(['sans1' => '0.520*dpt'], $options, '0.520*dpt',
new stack_cas_security(true));
$this->assertEquals(stack_input::VALID, $state->status);
$this->assertEquals('', $state->note);
$this->assertEquals('0.520*dpt', $state->contentsmodified);
$this->assertEquals('\[ 0.520\, \mathrm{dpt} \]', $state->contentsdisplayed);
$this->assertEquals('', $state->errors);
}
}

0 comments on commit bc32e2b

Please sign in to comment.