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

Deprecate Gameboard Filter #1254

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/components/navigation/IsaacApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export const IsaacApp = () => {
<TrackedRoute exact path="/progress" ifUser={isLoggedIn} component={MyProgress} />
<TrackedRoute exact path="/progress/:userIdOfInterest" ifUser={isLoggedIn} component={MyProgress} />
<TrackedRoute exact path={PATHS.MY_GAMEBOARDS} ifUser={isLoggedIn} component={MyGameboards} />
<TrackedRoute exact path={PATHS.GAMEBOARD_FILTER} ifUser={isNotPartiallyLoggedIn} component={GameboardFilter} />
<TrackedRoute exact path={PATHS.GAMEBOARD_FILTER} ifUser={isLoggedIn} component={GameboardFilter} />
<TrackedRoute exact path={PATHS.QUESTION_FINDER} component={QuestionFinder} />

{/* Teacher pages */}
Expand Down
31 changes: 2 additions & 29 deletions src/app/components/pages/Gameboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,12 @@ import {
useUserViewingContext
} from "../../services";
import {Redirect} from "react-router";
import queryString from "query-string";
import {StageAndDifficultySummaryIcons} from "../elements/StageAndDifficultySummaryIcons";
import {Markup} from "../elements/markup";
import classNames from "classnames";
import {skipToken} from "@reduxjs/toolkit/query";
import {ShowLoadingQuery} from "../handlers/ShowLoadingQuery";

function extractFilterQueryString(gameboard: GameboardDTO): string {
const csvQuery: {[key: string]: string} = {};
if (gameboard.gameFilter) {
Object.entries(gameboard.gameFilter).forEach(([key, values]) => {
csvQuery[key] = values.join(",");
});
}
return queryString.stringify(csvQuery, {encode: false});
}

const GameboardItemComponent = ({gameboard, question}: {gameboard: GameboardDTO, question: GameboardItem}) => {
let itemClasses = classNames("content-summary-link text-info bg-white", {"p-3": isPhy, "p-0": isAda});
const itemSubject = tags.getSpecifiedTag(TAG_LEVEL.subject, question.tags as TAG_ID[]);
Expand Down Expand Up @@ -109,7 +98,7 @@ const GameboardItemComponent = ({gameboard, question}: {gameboard: GameboardDTO,
</div>}
</div>
{question.audience && <StageAndDifficultySummaryIcons stack={isAda && below['sm'](deviceSize)} audienceViews={
isPhy && !isTutorOrAbove(currentUser) && uniqueStage ? [uniqueStage] : questionViewingContexts
isPhy && !isTutorOrAbove(currentUser) && uniqueStage ? [uniqueStage] : questionViewingContexts
} />}
</div>
{isAda && <div className={"list-caret vertical-center"}><img src={"/assets/common/icons/chevron_right.svg"} alt={"Go to question"}/></div>}
Expand Down Expand Up @@ -159,14 +148,6 @@ export const Gameboard = withRouter(({ location }) => {
const { data: gameboard } = gameboardQuery;
const user = useAppSelector(selectors.user.orNull);

// Show filter
const {filter} = queryString.parse(location.search);
let showFilter = false;
if (filter) {
const filterValue = filter instanceof Array ? filter[0] : filter;
showFilter = isDefined(filterValue) && filterValue.toLowerCase() === "true";
}

// Only log a gameboard view when we have a gameboard loaded:
useEffect(() => {
if (isDefined(gameboard) && isFound(gameboard)) {
Expand All @@ -180,25 +161,17 @@ export const Gameboard = withRouter(({ location }) => {
<small>
{`We're sorry, we were not able to find a ${siteSpecific("gameboard", "quiz")} with the id `}<code>{gameboardId}</code>{"."}
</small>
{isPhy && <div className="mt-4 text-center">
<Button tag={Link} to={PATHS.GAMEBOARD_FILTER} color="primary" outline className="btn-lg">
Generate a new gameboard
</Button>
</div>}
</h3>
</Container>;

return !gameboardId
? <Redirect to={PATHS.GAMEBOARD_FILTER} />
? <Redirect to={PATHS.QUESTION_FINDER} />
: <Container className="mb-5">
<ShowLoadingQuery
query={gameboardQuery}
defaultErrorTitle={`Error fetching ${siteSpecific("gameboard", "quiz")} with id: ${gameboardId}`}
ifNotFound={notFoundComponent}
thenRender={(gameboard) => {
if (showFilter) {
return <Redirect to={`${PATHS.GAMEBOARD_FILTER}?${extractFilterQueryString(gameboard)}#${gameboardId}`} />;
}
return <>
<TitleAndBreadcrumb currentPageTitle={gameboard && gameboard.title || `Filter Generated ${siteSpecific("Gameboard", "Quiz")}`}/>
<GameboardViewer gameboard={gameboard} className="mt-4 mt-lg-5" />
Expand Down
3 changes: 0 additions & 3 deletions src/app/components/pages/MyGameboards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ export const MyGameboards = () => {
{boards && boards.totalResults == 0 ?
<>
<h3 className="text-center mt-4">You have no {siteSpecific("gameboards", "quizzes")} to view.</h3>
{isPhy && <div className="text-center mt-3 mb-5">
<Button color="secondary" tag={Link} to={PATHS.GAMEBOARD_FILTER}>Create a gameboard</Button>
</div>}
</>
:
<>
Expand Down
Loading