Skip to content

Commit a6f4a67

Browse files
committed
GH-791 Add wrappers for more pre-select tasks
1 parent 02f6855 commit a6f4a67

File tree

1 file changed

+183
-0
lines changed

1 file changed

+183
-0
lines changed

classes/teststrategy/strategy.php

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use coding_exception;
2929
use Exception;
3030
use dml_exception;
31+
use local_catquiz\catquiz;
3132
use local_catquiz\catscale;
3233
use local_catquiz\local\model\model_item_param_list;
3334
use local_catquiz\local\model\model_strategy;
@@ -36,6 +37,20 @@
3637
use local_catquiz\output\attemptfeedback;
3738
use local_catquiz\teststrategy\info;
3839
use local_catquiz\teststrategy\preselect_task;
40+
use local_catquiz\teststrategy\preselect_task\addscalestandarderror;
41+
use local_catquiz\teststrategy\preselect_task\filterbyquestionsperscale;
42+
use local_catquiz\teststrategy\preselect_task\filterbystandarderror;
43+
use local_catquiz\teststrategy\preselect_task\filterbytestinfo;
44+
use local_catquiz\teststrategy\preselect_task\firstquestionselector;
45+
use local_catquiz\teststrategy\preselect_task\fisherinformation;
46+
use local_catquiz\teststrategy\preselect_task\lasttimeplayedpenalty;
47+
use local_catquiz\teststrategy\preselect_task\maximumquestionscheck;
48+
use local_catquiz\teststrategy\preselect_task\maybe_return_pilot;
49+
use local_catquiz\teststrategy\preselect_task\mayberemovescale;
50+
use local_catquiz\teststrategy\preselect_task\noremainingquestions;
51+
use local_catquiz\teststrategy\preselect_task\remove_uncalculated;
52+
use local_catquiz\teststrategy\preselect_task\removeplayedquestions;
53+
use local_catquiz\teststrategy\preselect_task\updatepersonability;
3954
use local_catquiz\teststrategy\progress;
4055
use local_catquiz\wb_middleware_runner;
4156
use moodle_exception;
@@ -400,4 +415,172 @@ protected function check_break(): result {
400415
// wrong in hindsight.
401416
return result::ok();
402417
}
418+
419+
/**
420+
* Checks if we have a new response. If not, presents the previous question again.
421+
*/
422+
protected function check_page_reload(): result {
423+
$this->progress = $this->context['progress'];
424+
if (
425+
($this->progress->is_first_question() && !$this->progress->get_last_question())
426+
|| $this->progress->has_new_response()
427+
|| $this->progress->get_force_new_question()
428+
) {
429+
return result::ok(null);
430+
}
431+
432+
return result::ok($this->progress->get_last_question());
433+
}
434+
435+
/**
436+
* Update the person ability of the user taking the quiz.
437+
*/
438+
protected function update_personability(): result {
439+
$updateabilitytask = new updatepersonability();
440+
$result = $updateabilitytask->run($this->context, fn ($context) => result::ok($context));
441+
return $result;
442+
}
443+
444+
/**
445+
* Add scale standarderror
446+
*
447+
* Now, this is just a wrapper to call the respective pre-select task.
448+
*/
449+
protected function add_scale_standarderror(): result {
450+
$addscalestderrtask = new addscalestandarderror();
451+
$result = $addscalestderrtask->run($this->context, fn ($context) => result::ok($context));
452+
return $result;
453+
}
454+
455+
/**
456+
* Maximum questions check
457+
*
458+
* Now, this is just a wrapper to call the respective pre-select task.
459+
*/
460+
protected function maximumquestionscheck(): result {
461+
$maximumquestionscheck = new maximumquestionscheck();
462+
$result = $maximumquestionscheck->run($this->context, fn ($context) => result::ok($context));
463+
return $result;
464+
}
465+
466+
/**
467+
* Remove played questions
468+
*
469+
* Now, this is just a wrapper to call the respective pre-select task.
470+
*/
471+
protected function removeplayedquestions(): result {
472+
$removeplayedquestions = new removeplayedquestions();
473+
$result = $removeplayedquestions->run($this->context, fn ($context) => result::ok($context));
474+
return $result;
475+
}
476+
477+
/**
478+
* Check for no remaining questions
479+
*
480+
* Now, this is just a wrapper to call the respective pre-select task.
481+
*/
482+
protected function noremainingquestions(): result {
483+
$noremainingquestions = new noremainingquestions();
484+
$result = $noremainingquestions->run($this->context, fn ($context) => result::ok($context));
485+
return $result;
486+
}
487+
488+
/**
489+
* Check if scales should be removed.
490+
*
491+
* Now, this is just a wrapper to call the respective pre-select task.
492+
*/
493+
protected function mayberemovescale(): result {
494+
$mayberemovescale = new mayberemovescale();
495+
$result = $mayberemovescale->run($this->context, fn ($context) => result::ok($context));
496+
return $result;
497+
}
498+
499+
/**
500+
* Calculate Fisher information
501+
*
502+
* Now, this is just a wrapper to call the respective pre-select task.
503+
*/
504+
protected function fisherinformation(): result {
505+
$fisherinformation = new fisherinformation();
506+
$result = $fisherinformation->run($this->context, fn ($context) => result::ok($context));
507+
return $result;
508+
}
509+
510+
/**
511+
* Maybe return a pilot question
512+
*
513+
* Now, this is just a wrapper to call the respective pre-select task.
514+
*/
515+
protected function maybereturnpilot(): result {
516+
$maybereturnpilot = new maybe_return_pilot();
517+
$result = $maybereturnpilot->run($this->context, fn ($context) => result::ok($context));
518+
return $result;
519+
}
520+
521+
/**
522+
* First question selector
523+
*
524+
* Now, this is just a wrapper to call the respective pre-select task.
525+
*/
526+
protected function first_question_selector(): result {
527+
$firstquestionselector = new firstquestionselector();
528+
$result = $firstquestionselector->run($this->context, fn ($context) => result::ok($context));
529+
return $result;
530+
}
531+
532+
/**
533+
* Adds last-time-played penalty
534+
*
535+
* Now, this is just a wrapper to call the respective pre-select task.
536+
*/
537+
protected function last_time_played_penalty(): result {
538+
$lasttimeplayedpenalty = new lasttimeplayedpenalty();
539+
$result = $lasttimeplayedpenalty->run($this->context, fn ($context) => result::ok($context));
540+
return $result;
541+
}
542+
543+
/**
544+
* Removes questions for which no item parameters were calculated yet
545+
*
546+
* Now, this is just a wrapper to call the respective pre-select task.
547+
*/
548+
protected function remove_uncalculated(): result {
549+
$removeuncalculated = new remove_uncalculated();
550+
$result = $removeuncalculated->run($this->context, fn ($context) => result::ok($context));
551+
return $result;
552+
}
553+
554+
/**
555+
* Filter by standarderror
556+
*
557+
* Now, this is just a wrapper to call the respective pre-select task.
558+
*/
559+
protected function filterbystandarderror(): result {
560+
$filterbystandarderror = new filterbystandarderror();
561+
$result = $filterbystandarderror->run($this->context, fn ($context) => result::ok($context));
562+
return $result;
563+
}
564+
565+
/**
566+
* Filter by test info
567+
*
568+
* Now, this is just a wrapper to call the respective pre-select task.
569+
*/
570+
protected function filterbytestinfo(): result {
571+
$filterbytestinfo = new filterbytestinfo();
572+
$result = $filterbytestinfo->run($this->context, fn ($context) => result::ok($context));
573+
return $result;
574+
}
575+
576+
/**
577+
* Filter by questions per scale
578+
*
579+
* Now, this is just a wrapper to call the respective pre-select task.
580+
*/
581+
protected function filterbyquestionsperscale(): result {
582+
$filterbyquestionsperscale = new filterbyquestionsperscale();
583+
$result = $filterbyquestionsperscale->run($this->context, fn ($context) => result::ok($context));
584+
return $result;
585+
}
403586
}

0 commit comments

Comments
 (0)