Skip to content
Merged
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
25 changes: 1 addition & 24 deletions cypress/e2e/2.Sim1/sim1.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ describe('Simulation 1 Initial Setup', () => {
cy.get('h2.h2-primary').should(
'contain', 'Resulting graph coefficients');
});
it('should navigate to the null hypothesis section', () => {
cy.get('[data-cy="nullNextButton"]').click();
cy.get('h2.h2-primary').should('contain', 'Defining null hypothesis');
});
});

describe('Graph Data', () => {
Expand All @@ -39,40 +35,21 @@ describe('Graph Data', () => {
cy.get('h2.h2-primary')
.should('contain', 'Resulting graph coefficients');
});
it('Null Hypothesis', () => {
cy.get('[data-cy="nullNextButton"]').click();
cy.get('h2.h2-primary')
.should('contain', 'Defining null hypothesis');
});
});

describe('Null Hypothesis', () => {
it('should navigate through resulting graph coefficients', () => {
cy.get('[data-cy="nullNextButton"]').click();
cy.get('#null-hypothesis').should(
'contain', 'Defining null hypothesis');
});
it('should allow selecting a different null hypothesis', () => {
cy.get('button').contains('Continue').first().click();
cy.get('input[name="nullHypothesis"]').clear();
cy.get('input[name="nullHypothesis"]').type('1');
cy.get('input[name="nullHypothesis"]').should('have.value', '1');
});

it('should submit the selected hypothesis and proceed', () => {
it('should move on to alternative hypothesis', () => {
cy.get('button').contains('Continue').first().click();
cy.get('#gotoTesting2d').click();
cy.get('#quiz-1').should('contain', 'Alternative hypothesis');
});
});

describe('Alternative Hypothesis', () => {
it('should navigate through the alternative hypothesis section', () => {
cy.get('button').contains('Continue').first().click();
// cy.get('#gotoTesting2d').click();
cy.get('#quiz-1').should('contain', 'Alternative hypothesis');
});

it('should show alternate hypothesis A', () => {
cy.get('#choice-A').should('contain', 'Check');
cy.get('#choice-A').click();
Expand Down
25 changes: 2 additions & 23 deletions media/js/src/simulations/simulation1/graphCoefficientsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import PropTypes from 'prop-types';

export const GraphCoefficients = ({
intercept, slope, stderror, plotType, slopes, stderrs,
onShowNullHypothesis, intercept3d, showNullHypothesis
intercept3d,
}) => {
const handleNextClick = () => {
onShowNullHypothesis();
};

return (
<div className="simulation__step-container d-flex">
Expand Down Expand Up @@ -62,14 +59,6 @@ export const GraphCoefficients = ({
`{SE(\\hat{\\beta_1})} = ${stderror.toFixed(3)}`} />
</div>
</div>
<div className="simulation__step-prompt">
<button className="btn btn-sm btn-success"
data-cy="nullNextButton"
disabled={showNullHypothesis}
onClick={handleNextClick}>
Continue &raquo;
</button>
</div>
</div>
)}
{(plotType === '3d' && slopes.length > 0) && (
Expand Down Expand Up @@ -120,14 +109,6 @@ export const GraphCoefficients = ({
`{SE(\\hat{\\beta_1})} = ${stderrs[0].toFixed(3)}`} />
</div>
</div>
<div className="simulation__step-prompt">
<button className="btn btn-sm btn-success"
data-cy="nullNextButton"
disabled={showNullHypothesis}
onClick={handleNextClick}>
Continue &raquo;
</button>
</div>
</div>
)}
</div>
Expand All @@ -142,7 +123,5 @@ GraphCoefficients.propTypes = {
plotType: PropTypes.string,
slopes: PropTypes.array,
stderrs: PropTypes.array,
onShowNullHypothesis: PropTypes.func,
intercept3d: PropTypes.number,
showNullHypothesis: PropTypes.bool,
intercept3d: PropTypes.number
};
11 changes: 5 additions & 6 deletions media/js/src/simulations/simulation1/hypothesisTest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Quiz } from './quiz';
import axios from 'axios';

export const HypothesisTest = ({
selectedAltHypothesis, appRvalue, tvalue, hypothesizedSlope, n,
selectedAltHypothesis, appRvalue, tvalue, n,
completedChoices, submissionId, plotType, isRedo, setIsRedo,
setIsHypothesisCompleted, isHypothesisCompleted, answers, setLockControls
}) => {
Expand All @@ -16,19 +16,19 @@ export const HypothesisTest = ({
let hypothesis;
let hypothesisTest;

const nullHypothesis = `\\Eta_0: {\\beta_1}=${hypothesizedSlope}`;
const nullHypothesis = `\\Eta_0: {\\beta_1}= 0`;

switch (selectedAltHypothesis) {
case 'A':
hypothesis = `\\Eta_1: {\\beta_1}~{\\neq}~${hypothesizedSlope}`;
hypothesis = `\\Eta_1: {\\beta_1}~{\\neq}~0`;
hypothesisTest = 'value_two_sided';
break;
case 'B':
hypothesis = `\\Eta_1: {\\beta_1}~{\\gt}~${hypothesizedSlope}`;
hypothesis = `\\Eta_1: {\\beta_1}~{\\gt}~0`;
hypothesisTest = 'value_right';
break;
case 'C':
hypothesis = `\\Eta_1: {\\beta_1}~{\\lt}~${hypothesizedSlope}`;
hypothesis = `\\Eta_1: {\\beta_1}~{\\lt}~0`;
hypothesisTest = 'value_left';
break;
default:
Expand Down Expand Up @@ -188,7 +188,6 @@ HypothesisTest.propTypes = {
appRvalue: PropTypes.number.isRequired,
tvalue: PropTypes.number.isRequired,
coursePK: PropTypes.number,
hypothesizedSlope: PropTypes.any.isRequired,
n: PropTypes.number.isRequired,
completedChoices: PropTypes.array.isRequired,
submissionId: PropTypes.number.isRequired,
Expand Down
62 changes: 13 additions & 49 deletions media/js/src/simulations/simulation1/nullHypothesisSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@ import PropTypes from 'prop-types';


export const NullHypothesisSection = ({
slope, stderror, tvalue, hypothesizedSlope,
startQuiz, plotType, slopes, stderrs, tvalue3d, startQuiz2,
setHypothesizedSlope, selectedAltHypothesis
slope, stderror, tvalue, startQuiz, plotType, slopes, stderrs,
tvalue3d, startQuiz2
}) => {

const handleNullHypothesis = (e) => {
setHypothesizedSlope(parseFloat(e.target.value));
};

useEffect(() => {
document.getElementById('null-hypothesis')
.scrollIntoView({ behavior: 'smooth' });

if (plotType === '3d') {
setHypothesizedSlope(0);
}
}, [plotType, setHypothesizedSlope]);
}, [plotType]);

const tEquation =
't = \\cfrac{\\hat{\\beta}_1 - \\beta_1}{SE(\\hat{\\beta_1})}';
Expand Down Expand Up @@ -50,33 +42,19 @@ export const NullHypothesisSection = ({
className="katex-inline" /> and observe the
outcome of the test statistic
<Katex tex={'t'} className="katex-inline" />.</p>
<p><em>For your first try, set <Katex tex={
'{\\beta_1}=0'} className="katex-inline" />.</em>
</p>
<div className="sub-content">
<div className="d-flex">
<label
className="me-2 form-label
align-self-center">
<Katex tex={
'{\\Eta_0} : {\\beta_1} ='
} />
</label>
<input size="10"
name="nullHypothesis"
className="form-control short-input"
type="number" min="-5" max="5"
disabled={selectedAltHypothesis}
value={hypothesizedSlope}
onChange={handleNullHypothesis} />
<div className="katex-block mt-3">
<Katex tex={
'{\\Eta_0} : {\\beta_1} = 0'
} />
</div>
<div className="katex-block mt-3">
<Katex tex={tEquation} />
</div>
<div className="katex-block mt-3">
<Katex tex={
// eslint-disable-next-line max-len
`t = \\cfrac{${slope.toFixed(3)} - ${hypothesizedSlope}}{${stderror.toFixed(3)}} = ${tvalue}`
`t = \\cfrac{${slope.toFixed(3)} - 0}{${stderror.toFixed(3)}} = ${tvalue}`
} />
</div>
</div>
Expand All @@ -97,28 +75,18 @@ export const NullHypothesisSection = ({
<Katex tex={'t'} className="katex-inline" />.
</p>
<div className="sub-content">
<div className="d-flex">
<label
className="me-2 form-label
align-self-center">
<Katex tex={
'{\\Eta_0} : {\\beta_1} ='
} />
</label>
<input size="10"
className="form-control short-input"
type="number" min="-5" max="5"
disabled={startQuiz}
value={hypothesizedSlope}
onChange={handleNullHypothesis} />
<div className="katex-block mt-3">
<Katex tex={
'{\\Eta_0} : {\\beta_1} = 0'
} />
</div>
<div className="katex-block mt-3">
<Katex tex={tEquation} />
</div>
<div className="katex-block mt-3">
<Katex tex={
// eslint-disable-next-line max-len
`t = \\cfrac{${slopes[0].toFixed(3)} - ${hypothesizedSlope}}{${stderrs[0].toFixed(3)}} = ${tvalue3d}`
`t = \\cfrac{${slopes[0].toFixed(3)} - 0}{${stderrs[0].toFixed(3)}} = ${tvalue3d}`
} />
</div>
</div>
Expand All @@ -136,13 +104,9 @@ NullHypothesisSection.propTypes = {
tvalue: PropTypes.number,
tvalue3d: PropTypes.number,
tEquation: PropTypes.string,
hypothesizedSlope: PropTypes.number,
handleNullHypothesis: PropTypes.func,
startQuiz: PropTypes.bool,
plotType: PropTypes.string,
slopes: PropTypes.array,
stderrs: PropTypes.array,
startQuiz2: PropTypes.bool,
setHypothesizedSlope: PropTypes.func,
selectedAltHypothesis: PropTypes.string
};
Loading
Loading