Skip to content

Allow for multiple registered contexts when deciding if content is relevant #1574

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

Open
wants to merge 1 commit into
base: redesign-2024
Choose a base branch
from

Conversation

axlewin
Copy link
Contributor

@axlewin axlewin commented Jul 10, 2025

(Ada): If a teacher has multiple registered contexts set, they should see content highlighted as relevant to them if it is relevant to any of their contexts (we currently just check the first).

Copy link

codecov bot commented Jul 10, 2025

Codecov Report

Attention: Patch coverage is 38.88889% with 33 lines in your changes missing coverage. Please review.

Project coverage is 40.29%. Comparing base (b6c36bf) to head (db199bc).
Report is 32 commits behind head on redesign-2024.

Files with missing lines Patch % Lines
src/app/services/userViewingContext.ts 56.25% 14 Missing ⚠️
src/app/components/content/IsaacAccordion.tsx 0.00% 4 Missing ⚠️
...p/components/elements/inputs/UserContextPicker.tsx 0.00% 4 Missing ⚠️
src/app/components/pages/GameboardBuilder.tsx 0.00% 4 Missing ⚠️
...nents/navigation/IntendedAudienceWarningBanner.tsx 25.00% 3 Missing ⚠️
...components/elements/modals/QuestionSearchModal.tsx 0.00% 2 Missing ⚠️
src/app/components/elements/PageTitle.tsx 0.00% 1 Missing ⚠️
src/app/components/pages/Gameboard.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           redesign-2024    #1574      +/-   ##
=================================================
+ Coverage          40.27%   40.29%   +0.01%     
=================================================
  Files                509      509              
  Lines              22684    22688       +4     
  Branches            6743     7553     +810     
=================================================
+ Hits                9137     9141       +4     
  Misses             13509    13509              
  Partials              38       38              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -43,17 +43,15 @@ import {useContext} from "react";
import {Immutable} from "immer";

export interface UseUserContextReturnType {
stage: STAGE;
contexts: UserContext[];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't feel neat, but we can't just convert the existing stage/exam board properties to arrays because we need to keep stages and exam boards paired up correctly (e.g. if a user has AQA GCSE & OCR A-Level set). We also only need one explanation (etc), so having a list of contexts inside UseUserContextReturnType instead of having the hook return a list of UseUserContextReturnType seems sensible?

if ((isPhy || explanation.examBoard === CONTEXT_SOURCE.DEFAULT) && explanation.stage === CONTEXT_SOURCE.DEFAULT && registeredContexts?.length) {
const registeredContextsWithExamBoards = isPhy ? registeredContexts.map(rc => ({stage: rc.stage, examBoard: EXAM_BOARD.ALL})) : registeredContexts;
contexts.push(...registeredContextsWithExamBoards);
explanation.stage = CONTEXT_SOURCE.REGISTERED;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we need to keep the stages/exam boards paired up for multiple registered contexts, we can't keep this in the original else if and push stages/exam boards as we encounter them.

@axlewin axlewin marked this pull request as ready for review July 10, 2025 15:32
@axlewin
Copy link
Contributor Author

axlewin commented Jul 11, 2025

@mwtrew - I've looked over your suggestion and agree it's a much nicer approach. There are a few test failures on that branch right now, but once that's sorted I'm happy for those changes to be merged into this. The only other thing I noticed is that that branch is hardcoding EXAM_BOARD.ALL instead of using EXAM_BOARD_DEFAULT_OPTION, and on a similar note the default explanation for physics exam boards is DEFAULT instead of NOT_IMPLEMENTED - I think the tests have also caught the latter, though.

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