Skip to content

Commit 493ed58

Browse files
authored
Merge pull request #671 from ccnmtl/hidepvalue
Hide pvalue
2 parents 61d5de0 + ab6adf8 commit 493ed58

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

cypress/e2e/2.Sim1/sim1.cy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ describe('P-Value and Critical Value', () => {
6969
cy.get('#pValue').type('0.05');
7070
cy.get('#pvalueInputButton').contains('Continue').click();
7171
cy.get('.answer-incorrect-container').should('exist');
72+
cy.get('[data-cy="pvalueReveal"]').click();
7273
cy.get('[data-cy="pvalueanswer"]').invoke('text').then((text) => {
7374
cy.get('#pValue').clear();
7475
cy.get('#pValue').type(text);

media/js/src/simulations/simulation1/pvalueComponent.jsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const PvalueComponent = ({
1515
const [isPvalCompareCorrect, setIsPvalCompareCorrect] = useState(null);
1616
const [pvalueComparison, setPvalueComparison] = useState(null);
1717
const [nullHypothesisChoice1, setNullHypothesisChoice1] = useState(null);
18+
const [showAnswer, setShowAnswer] = useState(false);
1819

1920

2021

@@ -199,15 +200,30 @@ export const PvalueComponent = ({
199200
<div className="answer-incorrect flex-shrink-0
200201
align-self-start">!</div>
201202
<div>
202-
The value is incorrect; it&rsquo;s
203-
<span data-cy="pvalueanswer"> {pvalue}.</span>
204-
{hypothesisTest === 'value_two_sided' && (
205-
<span>
206-
&nbsp;Note that this is a two-sided test and the
207-
table value must be multiplied by two.&nbsp;
208-
</span>
203+
The value is incorrect;
204+
Please try again. {' '}
205+
{!showAnswer ? (
206+
<button
207+
type="button"
208+
className="btn btn-link p-0"
209+
onClick={() => setShowAnswer(true)}
210+
data-cy="pvalueReveal">
211+
Reveal answer
212+
</button>
213+
) : (
214+
215+
<>
216+
It&apos;s {' '}
217+
<span data-cy="pvalueanswer">{ pvalue}</span>.
218+
{hypothesisTest === 'value_two_sided' && (
219+
<span>
220+
&nbsp;Note that this is a two-sided
221+
test and the table value must be
222+
multiplied by two.&nbsp;
223+
</span>
224+
)}
225+
</>
209226
)}
210-
Please try again.
211227
</div>
212228
</div>
213229
)}

0 commit comments

Comments
 (0)