Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/remove teststrategy middleware #795

Merged
merged 15 commits into from
Jan 24, 2025

Conversation

davidszkiba
Copy link
Contributor

Closes #791

Instead of using a set of middlewares to select the next question, the process is simplified a bit.

All required preselect tasks are now called in the strategy class. They can be overwritten by the subclasses of the different strategies.
For example, in strategy.php the preselect task filterbytestinfo is executed. If this is not needed for the classical CAT strategy, it can overwrite the call to this task to do nothing.
Basically, this is implementing the template method design pattern.

@davidszkiba davidszkiba self-assigned this Jan 17, 2025
This removes the checkitemparams.php preselect-task middleware and makes it a normal method of the strategy class.
This removes the checkbreak pre-select task middleware and makes it a normal method of the strategy class.
Since we are calling the preselect tasks directly via run now and do not
call the `process()` method in the abstract preselect_task class, the
`get_required_context_keys()` method is not called anymore.

Generally, this was not the best approach because its easy to use a
context key that is not listed in the `get_required_context_keys()`
method, so the actual code and the things defined there might diverge.

A better approach would be to use a class instead of an array for the
$context variable (e.g. preselect_context) and make sure it contains all
required fields as properties.
@davidszkiba davidszkiba force-pushed the refactor/remove-teststrategy-middleware branch from 48787e4 to f37d354 Compare January 24, 2025 13:09
@davidszkiba davidszkiba merged commit 448e6af into develop Jan 24, 2025
24 checks passed
@davidszkiba davidszkiba deleted the refactor/remove-teststrategy-middleware branch January 24, 2025 15:33
@davidszkiba
Copy link
Contributor Author

I've tested it but since it's a bigger change, I created a merge commit instead of rebasing so that in case something does not work as expected, it would be easy to revert the changes from this PR.

mona-shakiba pushed a commit that referenced this pull request Feb 10, 2025
mona-shakiba pushed a commit that referenced this pull request Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant