Skip to content

Commit

Permalink
GH-791 Make update personability a regular method
Browse files Browse the repository at this point in the history
  • Loading branch information
davidszkiba committed Jan 16, 2025
1 parent 738a254 commit 7699ded
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public function set_context(array $context): self {
*/
public function run(array &$context, callable $next): result {
$this->progress = $context['progress'];
$this->context = $context;

// If we do not know the answer to the last question, we do not have to
// update the person ability. Also, pilot questions should not be used
Expand Down
12 changes: 12 additions & 0 deletions classes/teststrategy/strategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
use local_catquiz\teststrategy\preselect_task\remove_uncalculated;
use local_catquiz\teststrategy\preselect_task\removeplayedquestions;
use local_catquiz\teststrategy\preselect_task\updatepersonability;
use local_catquiz\teststrategy\preselect_task\updatepersonability_testing;
use local_catquiz\teststrategy\progress;
use local_catquiz\wb_middleware_runner;
use moodle_exception;
Expand Down Expand Up @@ -201,6 +202,13 @@ public function return_next_testitem(array $context) {
$this->context = $val;
}

// Core methods called in every strategy.
$res = $this->update_personability();
if ($res->iserr()) {
return $res;
}
$context = $res->unwrap();

foreach ($this->get_preselecttasks() as $modifier) {
// When this is called for running tests, check if there is a
// X_testing class and if so, use that one.
Expand Down Expand Up @@ -480,6 +488,10 @@ protected function check_page_reload(): result {
*/
protected function update_personability(): result {
$updateabilitytask = new updatepersonability();
// When this is called for running tests, use the testing class.
if (getenv('USE_TESTING_CLASS_FOR')) {
$updateabilitytask = new updatepersonability_testing();
}
$result = $updateabilitytask->run($this->context, fn ($context) => result::ok($context));
return $result;
}
Expand Down
1 change: 0 additions & 1 deletion classes/teststrategy/strategy/classicalcat.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class classicalcat extends strategy {
*/
public function get_preselecttasks(): array {
return [
updatepersonability::class,
addscalestandarderror::class,
maximumquestionscheck::class,
removeplayedquestions::class,
Expand Down
1 change: 0 additions & 1 deletion classes/teststrategy/strategy/inferallsubscales.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class inferallsubscales extends strategy {
*/
public function get_preselecttasks(): array {
return [
updatepersonability::class,
firstquestionselector::class, // If this is the first question of this attempt, return it here.
addscalestandarderror::class,
maximumquestionscheck::class, // Cancel quiz attempt if we reached maximum of questions.
Expand Down
1 change: 0 additions & 1 deletion classes/teststrategy/strategy/infergreateststrength.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class infergreateststrength extends strategy {
*/
public function get_preselecttasks(): array {
return [
updatepersonability::class,
firstquestionselector::class, // If this is the first question of this attempt, return it here.
addscalestandarderror::class,
maximumquestionscheck::class, // Cancel quiz attempt if we reached maximum of questions.
Expand Down
1 change: 0 additions & 1 deletion classes/teststrategy/strategy/inferlowestskillgap.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class inferlowestskillgap extends strategy {
*/
public function get_preselecttasks(): array {
return [
updatepersonability::class,
firstquestionselector::class, // If this is the first question of this attempt, return it here.
addscalestandarderror::class,
maximumquestionscheck::class, // Cancel quiz attempt if we reached maximum of questions.
Expand Down
1 change: 0 additions & 1 deletion classes/teststrategy/strategy/relevantscales.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class relevantscales extends strategy {
*/
public function get_preselecttasks(): array {
return [
updatepersonability::class,
firstquestionselector::class, // If this is the first question of this attempt, return it here.
addscalestandarderror::class,
maximumquestionscheck::class, // Cancel quiz attempt if we reached maximum of questions.
Expand Down
1 change: 0 additions & 1 deletion classes/teststrategy/strategy/teststrategy_fastest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ class teststrategy_fastest extends strategy {
*/
public function get_preselecttasks(): array {
return [
updatepersonability::class,
fisherinformation::class,
addscalestandarderror::class,
maximumquestionscheck::class,
Expand Down

0 comments on commit 7699ded

Please sign in to comment.