Skip to content

Commit

Permalink
Linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidszkiba committed Oct 8, 2024
1 parent 9d1771f commit b6fd9be
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
11 changes: 8 additions & 3 deletions catmodel/mixedraschbirnbaum/tests/mixedraschbirnbaum_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@ public function test_calculate_params_returns_expected_values($itemresponse, arr
$this->assertEqualsWithDelta($expected['guessing'], $result['guessing'], 0.0001);
}

/**
* Data provider for test_calculate_params_returns_expected_values
*
* @return array
*/
public static function calculate_params_returns_expected_values_provider(): array {
return [
[
'itemresponse' => [new model_item_response(0.3, (new model_person_param(1))->set_ability(0.2))],
'first' => [
'itemresponse' => [new model_item_response(0.3, (new model_person_param(1, 1))->set_ability(0.2))],
'expected' => ['difficulty' => 1.2041, 'discrimination' => 3.0, 'guessing' => 0.0],
]
],
];
}

Expand Down
9 changes: 7 additions & 2 deletions catmodel/rasch/tests/rasch_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ public function test_calculate_params_returns_expected_values($itemresponse, arr
$this->assertEqualsWithDelta($expected['difficulty'], $result['difficulty'], 0.0001);
}

/**
* Data provider for test_calculate_params_returns_expected_values
*
* @return array
*/
public static function calculate_params_returns_expected_values_provider(): array {
return [
[
'itemresponse' => [new model_item_response(0.3, (new model_person_param(1))->set_ability(0.2))],
'itemresponse' => [new model_item_response(0.3, (new model_person_param(1, 1))->set_ability(0.2))],
'expected' => ['difficulty' => 5.5],
]
],
];
}

Expand Down
9 changes: 7 additions & 2 deletions catmodel/raschbirnbaum/tests/raschbirnbaum_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,17 @@ public function test_calculate_params_returns_expected_values($itemresponse, arr
$this->assertEqualsWithDelta($expected['discrimination'], $result['discrimination'], 0.0001);
}

/**
* Data provider for test_calculate_params_returns_expected_values
*
* @return array
*/
public static function calculate_params_returns_expected_values_provider(): array {
return [
[
'itemresponse' => [new model_item_response(0.3, (new model_person_param(1))->set_ability(0.2))],
'itemresponse' => [new model_item_response(0.3, (new model_person_param(1, 1))->set_ability(0.2))],
'expected' => ['difficulty' => 1.4974, 'discrimination' => 3.0],
]
],
];
}

Expand Down
4 changes: 2 additions & 2 deletions classes/catcalc.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ public static function estimate_item_params(array $itemresponse, model_model $mo
/**
* Builds the jacobian function for item params and the given model.
*
* @param array<model_item_response> $itemresponse
* @param array $itemresponse
* @param catcalc_item_estimator $model
*
* @return mixed
*
*/
public static function build_itemparam_jacobian(array $itemresponse, catcalc_item_estimator $model) {
public static function build_itemparam_jacobian(array $itemresponse, catcalc_item_estimator $model): mixed {
// Define Jacobi vector (1st derivative) of the Log Likelihood.
$funs = [];

Expand Down
3 changes: 2 additions & 1 deletion tests/catcalc_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Exception;
use local_catquiz\local\model\model_item_param;
use local_catquiz\local\model\model_item_param_list;
use local_catquiz\local\model\model_model;
use local_catquiz\local\model\model_responses;
use moodle_exception;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
Expand Down Expand Up @@ -147,7 +148,7 @@ public static function simulation_steps_calculated_ability_provider(): array {
public function test_build_item_param_jacobian() {
$itemresponse = [];
$mr = new model_responses();
$model = new raschbirnbaum($mr, 'raschbirnbaum');
$model = model_model::get_instance('raschbirnbaum');
$this->assertEquals(fn () => 'b', catcalc::build_itemparam_jacobian($itemresponse, $model));
}

Expand Down
4 changes: 3 additions & 1 deletion tests/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ function loadresponsesforperson($filename, $person = 0): array {
*
* @param string $filename The file to load the responses from.
* @param string $label The label of the item.
* @param string $scale
* @return model_responses
*/
function loadresponsesforitem($filename, $label, $scale = 'Gesamt'): model_responses {
function loadresponsesforitem(string $filename, string $label, string $scale = 'Gesamt'): model_responses {
global $CFG;
if (($handle = fopen($filename, "r")) === false) {
throw new UnexpectedValueException("Can not open file: " . $filename);
Expand Down Expand Up @@ -107,6 +108,7 @@ function loadresponsesforitem($filename, $label, $scale = 'Gesamt'): model_respo
* model_person_param object.
*
* @param string $filename
* @param string $scale
* @return model_person_param_list
* @throws UnexpectedValueException
*/
Expand Down

0 comments on commit b6fd9be

Please sign in to comment.