Skip to content

Commit 7217136

Browse files
committed
remove confusing text from View Test page
- no longer show "You are viewing the rubric for this test" - no longer show the "Description" heading
1 parent 9354fb6 commit 7217136

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/app/components/elements/quiz/QuizContentsComponent.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,16 @@ function QuizDetails({attempt, sections, questions, pageLink}: QuizAttemptProps)
123123

124124
function QuizHeader({attempt, preview, view, user}: QuizAttemptProps | QuizViewProps) {
125125
const dispatch = useAppDispatch();
126-
if (preview || view) {
127-
const quiz = view ? view.quiz : attempt.quiz;
126+
if (view) {
127+
return isTeacherOrAbove(user) && <Button className="float-end ms-2 mb-2" onClick={() => dispatch(showQuizSettingModal(view.quiz!))}>Set Test</Button>;
128+
}
129+
else if (preview) {
128130
return <>
129131
{preview && <EditContentButton doc={attempt.quiz} />}
130132
<div data-testid="quiz-action" className="d-flex">
131133
<p>{ preview ? "You are previewing this test." : "You are viewing the rubric for this test."}</p>
132134
<Spacer />
133-
{isTeacherOrAbove(user) && <Button onClick={() => dispatch(showQuizSettingModal(quiz!))}>Set Test</Button>}
135+
{isTeacherOrAbove(user) && <Button onClick={() => dispatch(showQuizSettingModal(attempt.quiz!))}>Set Test</Button>}
134136
</div>
135137
</>;
136138
} else if (isDefined(attempt.quizAssignment)) {
@@ -165,8 +167,8 @@ function QuizRubric({attempt, view}: Pick<QuizAttemptProps | QuizViewProps, "att
165167
const rubric = attempt ? attempt.quiz?.rubric : view?.quiz?.rubric;
166168
const renderRubric = (rubric?.children || []).length > 0;
167169
return <div>
168-
{rubric && renderRubric && <div>
169-
<h4>Instructions</h4>
170+
{rubric && renderRubric && <div data-testid="quiz-rubric">
171+
{!view && <h4>Instructions</h4>}
170172
<IsaacContentValueOrChildren value={rubric.value}>
171173
{rubric.children}
172174
</IsaacContentValueOrChildren>

src/test/helpers/quiz.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export const expectErrorMessage = expectTextInElementWithId('error-message');
2424

2525
export const expectActionMessage = expectTextInElementWithId('quiz-action');
2626

27+
export const expectRubric = expectTextInElementWithId('quiz-rubric');
28+
2729
export const setTestButton = () => screen.queryByRole('button', {name: "Set Test"});
2830

2931
export const editButton = () => screen.queryByRole('heading', {name: "Published ✎"});

src/test/pages/QuizView.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { expectLinkWithEnabledBackwardsNavigation, expectH1, expectH4, expectTitledSection, expectUrl } from "../testUtils";
1+
import { expectLinkWithEnabledBackwardsNavigation, expectH1, expectH4, expectUrl } from "../testUtils";
22
import {mockRubrics} from "../../mocks/data";
3-
import { editButton, expectActionMessage, expectAdaBreadCrumbs, expectErrorMessage, expectPhyBreadCrumbs, expectSidebarToggle, previewButton, renderQuizPage, setTestButton, sideBarTestCases, testSectionsHeader } from "../helpers/quiz";
3+
import { editButton, expectAdaBreadCrumbs, expectErrorMessage, expectPhyBreadCrumbs, expectRubric, expectSidebarToggle, previewButton, renderQuizPage, setTestButton, sideBarTestCases, testSectionsHeader } from "../helpers/quiz";
44
import { isPhy, siteSpecific } from "../../app/services";
5-
import { screen } from "@testing-library/react";
5+
import {screen } from "@testing-library/react";
66

77
describe("QuizView", () => {
88
const quizId = Object.keys(mockRubrics)[0];
@@ -24,9 +24,9 @@ describe("QuizView", () => {
2424
expectH1(rubric.title);
2525
});
2626

27-
it('shows message about this page', async () => {
27+
it('does not show message about this page', async () => {
2828
await studentViewsQuiz();
29-
expectActionMessage('You are viewing the rubric for this test.');
29+
expect(screen.queryByTestId("quiz-action")).not.toBeInTheDocument();
3030
});
3131

3232
it('does not show Set Test button', async () => {
@@ -36,7 +36,7 @@ describe("QuizView", () => {
3636

3737
it('shows quiz rubric', async () => {
3838
await studentViewsQuiz();
39-
expectTitledSection("Instructions", rubric.rubric?.children?.[0].value);
39+
expectRubric(rubric.rubric?.children?.[0].value);
4040
});
4141

4242
it("does not show Test sections", async () => {

0 commit comments

Comments
 (0)