diff --git a/catmodel/mixedraschbirnbaum/tests/mixedraschbirnbaum_test.php b/catmodel/mixedraschbirnbaum/tests/mixedraschbirnbaum_test.php index c4fc4dfd4..847100c6c 100644 --- a/catmodel/mixedraschbirnbaum/tests/mixedraschbirnbaum_test.php +++ b/catmodel/mixedraschbirnbaum/tests/mixedraschbirnbaum_test.php @@ -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], - ] + ], ]; } diff --git a/catmodel/rasch/tests/rasch_test.php b/catmodel/rasch/tests/rasch_test.php index 2a25c1c1d..a7b244ec6 100644 --- a/catmodel/rasch/tests/rasch_test.php +++ b/catmodel/rasch/tests/rasch_test.php @@ -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], - ] + ], ]; } diff --git a/catmodel/raschbirnbaum/tests/raschbirnbaum_test.php b/catmodel/raschbirnbaum/tests/raschbirnbaum_test.php index 5257e47d0..e30461bb8 100644 --- a/catmodel/raschbirnbaum/tests/raschbirnbaum_test.php +++ b/catmodel/raschbirnbaum/tests/raschbirnbaum_test.php @@ -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], - ] + ], ]; } diff --git a/classes/catcalc.php b/classes/catcalc.php index 1acc08771..ae1aaecf0 100644 --- a/classes/catcalc.php +++ b/classes/catcalc.php @@ -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 $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 = []; diff --git a/tests/catcalc_test.php b/tests/catcalc_test.php index db86c69eb..591a4084e 100644 --- a/tests/catcalc_test.php +++ b/tests/catcalc_test.php @@ -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; @@ -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)); } diff --git a/tests/lib.php b/tests/lib.php index 18972c369..16382de46 100644 --- a/tests/lib.php +++ b/tests/lib.php @@ -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); @@ -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 */