Skip to content

Commit 95a96e7

Browse files
committed
Add example questions to subject overviews
1 parent 6d52ec2 commit 95a96e7

File tree

5 files changed

+46
-9
lines changed

5 files changed

+46
-9
lines changed

src/app/components/elements/list-groups/ListView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export const ListView = ({items, className, ...rest}: ListViewProps & ListViewIt
256256
return <EventListViewItem key={index} {...rest} item={item}/>;
257257
case (DOCUMENT_TYPE.QUIZ):
258258
return <QuizListViewItem key={index} {...rest} item={item}/>;
259-
case SEARCH_RESULT_TYPE.GAMEBOARD:
259+
case SEARCH_RESULT_TYPE.QUESTION_DECK:
260260
return <QuestionDeckListViewItem key={index} {...rest} item={item}/>;
261261
default:
262262
// Do not render this item if there is no matching DOCUMENT_TYPE

src/app/components/pages/SubjectLandingPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const LandingPageFooter = ({context}: {context: PageContextState}) => {
9292
// TODO: are we going to make subject-specific news?
9393
const {data: news} = useGetNewsPodListQuery({subject: "physics"});
9494

95-
return <Row className={classNames("mt-5 py-4 row-cols-1 row-cols-md-2")}>
95+
return <Row className={classNames("mt-2 py-4 row-cols-1 row-cols-md-2")}>
9696
<div className="d-flex flex-column mt-3">
9797
{/* if there are books, display books. otherwise, display news */}
9898
{books.length > 0

src/app/components/pages/SubjectOverviewPage.tsx

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { RouteComponentProps, withRouter } from "react-router";
33
import { Container } from "reactstrap";
44
import { TitleAndBreadcrumb } from "../elements/TitleAndBreadcrumb";
55
import { useUrlPageTheme } from "../../services/pageContext";
6-
import { HUMAN_SUBJECTS, isDefined, LEARNING_STAGE, LearningStage, PHY_NAV_SUBJECTS, Subject } from "../../services";
7-
import { PageContextState } from "../../../IsaacAppTypes";
8-
import { ListViewCardProps, ListViewCards } from "../elements/list-groups/ListView";
6+
import { above, HUMAN_SUBJECTS, isDefined, LEARNING_STAGE, LearningStage, PHY_NAV_SUBJECTS, SEARCH_RESULT_TYPE, subject, Subject, SUBJECTS, useDeviceSize } from "../../services";
7+
import { PageContextState, ShortcutResponse } from "../../../IsaacAppTypes";
8+
import { ListView, ListViewCardProps, ListViewCards, QuestionDeckListViewItem } from "../elements/list-groups/ListView";
99
import { LandingPageFooter } from "./SubjectLandingPage";
1010
import { DifficultyIcon } from "../elements/svg/DifficultyIcons";
1111

1212
const SubjectCards = ({context}: { context: PageContextState }) => {
13+
const deviceSize = useDeviceSize();
14+
1315
if (!isDefined(context?.subject)) return null;
1416

1517
const humanSubject = context?.subject && HUMAN_SUBJECTS[context.subject];
@@ -77,14 +79,41 @@ const SubjectCards = ({context}: { context: PageContextState }) => {
7779
icon: `/assets/phy/icons/redesign/subject-${context.subject}.svg`,
7880
}
7981
});
80-
} //hrm
82+
}
8183

82-
return <ListViewCards showBlanks cards={cards
84+
return <ListViewCards showBlanks={above["lg"](deviceSize)} cards={cards
8385
.sort((a, b) => a ? (b ? 0 : -1) : 1) // put nulls at the end
8486
.filter((x, i, a) => x || (i % 2 === 0 ? a[i + 1] : a[i - 1])) // remove pairs of nulls
8587
} />;
8688
};
8789

90+
const ExampleQuestions = ({ subject }: { subject: Subject }) => {
91+
const items: { [key in Subject]: ShortcutResponse[] } = {
92+
maths: [{
93+
title: "Sample Maths Questions",
94+
type: SEARCH_RESULT_TYPE.QUESTION_DECK,
95+
id: "sample_maths_questions",
96+
}],
97+
physics: [/*{
98+
title: "Sample Physics Questions",
99+
type: SEARCH_RESULT_TYPE.QUESTION_DECK,
100+
id: "sample_phy_questions",
101+
}*/], // Uncomment when physics questions are available
102+
chemistry: [{
103+
title: "Sample Chemistry Questions",
104+
type: SEARCH_RESULT_TYPE.QUESTION_DECK,
105+
id: "sample_chem_questions",
106+
}],
107+
biology: [{
108+
title: "Sample Biology Questions",
109+
type: SEARCH_RESULT_TYPE.QUESTION_DECK,
110+
id: "sample_bio_questions",
111+
}],
112+
};
113+
114+
return items[subject].length > 0 ? <ListView items={items[subject]} /> : null;
115+
};
116+
88117
export const SubjectOverviewPage = withRouter((props: RouteComponentProps) => {
89118
const pageContext = useUrlPageTheme();
90119

@@ -149,7 +178,7 @@ export const SubjectOverviewPage = withRouter((props: RouteComponentProps) => {
149178
</ul>
150179
</p>
151180

152-
{/* <ExampleQuestions/> */}
181+
<ExampleQuestions subject={pageContext.subject} />
153182

154183
<LandingPageFooter context={pageContext} />
155184
</div>}

src/app/services/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ export function isAQuestionLikeDoc(doc: ContentDTO): doc is IsaacQuestionPageDTO
924924

925925
export enum SEARCH_RESULT_TYPE {
926926
SHORTCUT = "shortcut",
927-
GAMEBOARD = "gameboard",
927+
QUESTION_DECK = "question deck",
928928
}
929929

930930
export const documentDescription: {[documentType in DOCUMENT_TYPE]: string} = {

src/scss/phy/list-groups.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
&:not(:first-child) {
3636
border-top: 1px solid var(--border-light);
3737
}
38+
&:nth-child(1) {
39+
border-top-left-radius: inherit;
40+
border-top-right-radius: inherit;
41+
}
42+
&:nth-last-child(1) {
43+
border-bottom-left-radius: inherit;
44+
border-bottom-right-radius: inherit;
45+
}
3846
}
3947

4048
@include media-breakpoint-up(lg) {

0 commit comments

Comments
 (0)