Skip to content

Fix Django Debug Toolbar redirect loop in Quizzes#800

Merged
Kobzol merged 4 commits intomrlvsb:masterfrom
DanielKrasny:quiz_redirect_loop
Dec 20, 2025
Merged

Fix Django Debug Toolbar redirect loop in Quizzes#800
Kobzol merged 4 commits intomrlvsb:masterfrom
DanielKrasny:quiz_redirect_loop

Conversation

@DanielKrasny
Copy link
Contributor

Closes #739.

I have modified the Quiz middleware to exclude Django Debug Toolbar endpoints from redirection. I also added the info endpoint to the excluded ones, since it may be useful for the frontend and does not output any information that could negatively interrupt the quiz process. Finally, I completely removed notifications from the main layout during the quiz, as I believe notifications are unnecessary while taking a quiz. It also prevents calling notification/all endpoint, which redirects to quiz now.

Copy link
Collaborator

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I think that the whole redirect middleware should be reworked or removed. The current approach just doesn't work at all... A more granular denylist approach like in #745 might be a better idea.

@DanielKrasny
Copy link
Contributor Author

I agree that my PR looks more like a workaround than a "clean fix." Since the mentioned PR has not been merged yet, I am cautious about making any breaking changes around it. I would prefer to see the decorator used in multiple cases, so we don't end up with something like @prohibit_during_quiz.

I have removed the changes you found problematic. Should we merge it as just a fix for #739, or close it and explore another approach without the middleware?

Copy link
Collaborator

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that prohibiting during quizzes and tests will be essentially the same thing, so we could just use a single decorator that blocks an endpoint if you have an active test exam OR an active quiz.

Nevertheless, this looks like a clear fix to the original issue, so I'm fine with merging it as is.

@Kobzol Kobzol added this pull request to the merge queue Dec 20, 2025
Merged via the queue into mrlvsb:master with commit db8e6a1 Dec 20, 2025
7 checks passed
@DanielKrasny DanielKrasny deleted the quiz_redirect_loop branch December 20, 2025 22:46
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.

Infinite loop when clicking the answer

2 participants