Skip to content

Test pages types overhaul#2209

Open
jacbn wants to merge 7 commits into
mainfrom
feature/test-pages-overhaul
Open

Test pages types overhaul#2209
jacbn wants to merge 7 commits into
mainfrom
feature/test-pages-overhaul

Conversation

@jacbn

@jacbn jacbn commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Overhauls the test pages' types to drastically increase code readability and robustness.

Quizzes across these pages can either be simplified rubric summary objects (if you have not yet committed to starting the test), or full quiz objects (if viewing a past attempt, previewing, or coming from an assignment). Previously, we represented the difference with two entirely separate objects:

// summary object
interface QuizViewProps extends QuizProps {
    attempt?: undefined;
    view: QuizView;
    preview?: undefined;
    page?: undefined;
    pageLink?: undefined;
    questions?: undefined;
    sections?: undefined;
}

// full quiz
interface QuizAttemptProps extends QuizProps {
    attempt: QuizAttemptDTO
    view?: undefined;
    preview?: boolean;
    page: number | null;
    pageLink: PageLinkCreator;
    questions: QuestionDTO[];
    sections: { [id: string]: IsaacQuizSectionDTO };
}

// (along with these props, shared between the two)
interface QuizProps {
    user: RegisteredUserDTO;
    pageHelp: React.ReactElement;
    studentUser?: UserSummaryDTO;
    quizAssignmentId?: string;
}

This is fairly nasty for multiple reasons:

  • All of these properties exist (undefined or not) across all quiz-related components, requiring conditional if-exists checks that would already be answered if we knew the type in advance;
  • The rubric exists in entirely different places across the two interfaces: QuizViewProps.view contains a DetailedQuizSummaryDTO (containing the rubric), whereas QuizAttemptProps.attempt contains an IsaacQuizDTO with this same information.
    • Indeed, DetailedQuizSummaryDTO is a strict subset of IsaacQuizDTO, which implies a significantly neater strategy of sharing an object between the two.

A majority of the changes in this PR migrate the above types into this new format:

type QuizContents = {
    questions: QuestionDTO[];
    sections: { [id: string]: IsaacQuizSectionDTO };
    pageLink: (page?: number) => string;
};

export type FullQuizInfo = {
    quiz: IsaacQuizDTO;
    attempt: QuizAttemptDTO;
    quizContents: QuizContents;
};

export type QuizSummaryInfo = {
    quiz: DetailedQuizSummaryDTO;
}

export type QuizProps = {
    user: RegisteredUserDTO;
    pageHelp: React.ReactElement;
    studentUser?: UserSummaryDTO;
    quizAssignmentId?: string;
    page?: number;
} & (FullQuizInfo | QuizSummaryInfo);

We can use the type QuizProps & FullQuizInfo whenever we require parameters to be those of a complete quiz, and similarly for QuizProps & QuizSummaryInfo if only the summary is required. We can also use QuizProps without a second modifier in the case we can use either; in particular, note that QuizProps.quiz is of type IsaacQuizDTO | DetailedQuizSummaryDTO, for which quiz.rubric is a valid property in both cases, and so never requires further type checking or complication.

Comment thread src/app/components/elements/cards/GameboardCard.tsx Fixed
@jsharkey13 jsharkey13 force-pushed the feature/test-pages-overhaul branch 2 times, most recently from b20310d to c504e1d Compare June 15, 2026 08:54
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.42308% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 43.57%. Comparing base (bc6477b) to head (4568679).

Files with missing lines Patch % Lines
...p/components/pages/quizzes/QuizAttemptFeedback.tsx 0.00% 6 Missing ⚠️
.../app/components/pages/quizzes/QuizDoAssignment.tsx 25.00% 3 Missing ⚠️
...rc/app/components/elements/sidebar/QuizSidebar.tsx 90.00% 1 Missing ⚠️
...c/app/components/pages/quizzes/PracticeQuizzes.tsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2209      +/-   ##
==========================================
+ Coverage   43.54%   43.57%   +0.02%     
==========================================
  Files         597      597              
  Lines       25217    25232      +15     
  Branches     8378     8380       +2     
==========================================
+ Hits        10981    10994      +13     
+ Misses      14187    14181       -6     
- Partials       49       57       +8     

☔ View full report in Codecov by Harness.
📢 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.

@jacbn jacbn marked this pull request as ready for review June 15, 2026 13:06
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.

2 participants