Skip to content

Commit 7699ded

Browse files
committed
GH-791 Make update personability a regular method
1 parent 738a254 commit 7699ded

File tree

8 files changed

+13
-6
lines changed

8 files changed

+13
-6
lines changed

classes/teststrategy/preselect_task/updatepersonability.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public function set_context(array $context): self {
167167
*/
168168
public function run(array &$context, callable $next): result {
169169
$this->progress = $context['progress'];
170+
$this->context = $context;
170171

171172
// If we do not know the answer to the last question, we do not have to
172173
// update the person ability. Also, pilot questions should not be used

classes/teststrategy/strategy.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
use local_catquiz\teststrategy\preselect_task\remove_uncalculated;
5252
use local_catquiz\teststrategy\preselect_task\removeplayedquestions;
5353
use local_catquiz\teststrategy\preselect_task\updatepersonability;
54+
use local_catquiz\teststrategy\preselect_task\updatepersonability_testing;
5455
use local_catquiz\teststrategy\progress;
5556
use local_catquiz\wb_middleware_runner;
5657
use moodle_exception;
@@ -201,6 +202,13 @@ public function return_next_testitem(array $context) {
201202
$this->context = $val;
202203
}
203204

205+
// Core methods called in every strategy.
206+
$res = $this->update_personability();
207+
if ($res->iserr()) {
208+
return $res;
209+
}
210+
$context = $res->unwrap();
211+
204212
foreach ($this->get_preselecttasks() as $modifier) {
205213
// When this is called for running tests, check if there is a
206214
// X_testing class and if so, use that one.
@@ -480,6 +488,10 @@ protected function check_page_reload(): result {
480488
*/
481489
protected function update_personability(): result {
482490
$updateabilitytask = new updatepersonability();
491+
// When this is called for running tests, use the testing class.
492+
if (getenv('USE_TESTING_CLASS_FOR')) {
493+
$updateabilitytask = new updatepersonability_testing();
494+
}
483495
$result = $updateabilitytask->run($this->context, fn ($context) => result::ok($context));
484496
return $result;
485497
}

classes/teststrategy/strategy/classicalcat.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class classicalcat extends strategy {
7575
*/
7676
public function get_preselecttasks(): array {
7777
return [
78-
updatepersonability::class,
7978
addscalestandarderror::class,
8079
maximumquestionscheck::class,
8180
removeplayedquestions::class,

classes/teststrategy/strategy/inferallsubscales.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class inferallsubscales extends strategy {
8585
*/
8686
public function get_preselecttasks(): array {
8787
return [
88-
updatepersonability::class,
8988
firstquestionselector::class, // If this is the first question of this attempt, return it here.
9089
addscalestandarderror::class,
9190
maximumquestionscheck::class, // Cancel quiz attempt if we reached maximum of questions.

classes/teststrategy/strategy/infergreateststrength.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class infergreateststrength extends strategy {
9090
*/
9191
public function get_preselecttasks(): array {
9292
return [
93-
updatepersonability::class,
9493
firstquestionselector::class, // If this is the first question of this attempt, return it here.
9594
addscalestandarderror::class,
9695
maximumquestionscheck::class, // Cancel quiz attempt if we reached maximum of questions.

classes/teststrategy/strategy/inferlowestskillgap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class inferlowestskillgap extends strategy {
8484
*/
8585
public function get_preselecttasks(): array {
8686
return [
87-
updatepersonability::class,
8887
firstquestionselector::class, // If this is the first question of this attempt, return it here.
8988
addscalestandarderror::class,
9089
maximumquestionscheck::class, // Cancel quiz attempt if we reached maximum of questions.

classes/teststrategy/strategy/relevantscales.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class relevantscales extends strategy {
8484
*/
8585
public function get_preselecttasks(): array {
8686
return [
87-
updatepersonability::class,
8887
firstquestionselector::class, // If this is the first question of this attempt, return it here.
8988
addscalestandarderror::class,
9089
maximumquestionscheck::class, // Cancel quiz attempt if we reached maximum of questions.

classes/teststrategy/strategy/teststrategy_fastest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class teststrategy_fastest extends strategy {
7979
*/
8080
public function get_preselecttasks(): array {
8181
return [
82-
updatepersonability::class,
8382
fisherinformation::class,
8483
addscalestandarderror::class,
8584
maximumquestionscheck::class,

0 commit comments

Comments
 (0)