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

Revert "Set up state for answers" #612

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 3 additions & 4 deletions media/js/src/simulations/simulation1/criticalValue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { saveAnswer } from '../../utils/utils';

export const CriticalValue = ({
hypothesisTest2validate, tvalue, n, alpha, hypothesisTest, hypothesis,
nullHypothesis, submissionId, plotType, criticalValues, isRedo,
setHypothesisTest2validate, answers
nullHypothesis, submissionId, plotType,
setHypothesisTest2validate, criticalValues, isRedo,
}) => {
const [nullHypothesisChoice2, setNullHypothesisChoice2] = useState(null);
const [userCriticalValue, setUserCriticalValue] = useState('');
Expand Down Expand Up @@ -448,6 +448,5 @@ CriticalValue.propTypes = {
plotType: PropTypes.string.isRequired,
setHypothesisTest2validate: PropTypes.func.isRequired,
criticalValues: PropTypes.object,
isRedo: PropTypes.bool,
answers: PropTypes.array
isRedo: PropTypes.bool
};
7 changes: 2 additions & 5 deletions media/js/src/simulations/simulation1/hypothesisTest.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import axios from 'axios';
export const HypothesisTest = ({
selectedAltHypothesis, appRvalue, tvalue, hypothesizedSlope, n,
completedChoices, submissionId, plotType, setSelectedAltHypothesis,
setIsHypothesisCompleted, isRedo, setIsRedo, isHypothesisCompleted,
answers
setIsHypothesisCompleted, isRedo, setIsRedo, isHypothesisCompleted
}) => {
const [pvalues, setPvalues] = useState(null);
const [alpha, setAlpha] = useState(null);
Expand Down Expand Up @@ -162,7 +161,6 @@ export const HypothesisTest = ({
setIsRedo={setIsRedo}
tvalue={tvalue}
pvalue={parseFloat(pvalue)}
answers={answers}
alpha={alpha}
hypothesis={hypothesis}
nullHypothesis={nullHypothesis}
Expand Down Expand Up @@ -196,6 +194,5 @@ HypothesisTest.propTypes = {
setIsHypothesisCompleted: PropTypes.func,
isRedo: PropTypes.bool,
setIsRedo: PropTypes.func,
isHypothesisCompleted: PropTypes.bool,
answers: PropTypes.array
isHypothesisCompleted: PropTypes.bool
};
5 changes: 2 additions & 3 deletions media/js/src/simulations/simulation1/pvalueComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
export const PvalueComponent = ({
pvalue, tvalue, submissionId, hypothesis, nullHypothesis,
alpha, hypothesisTest1validate, setHypothesisTest1validate,
plotType, isRedo, hypothesisTest, answers
plotType, isRedo, hypothesisTest
}) => {

const [userPvalue, setUserPvalue] = useState('');
Expand Down Expand Up @@ -392,6 +392,5 @@ PvalueComponent.propTypes = {
setHypothesisTest1validate: PropTypes.func,
plotType: PropTypes.string,
isRedo: PropTypes.bool,
hypothesisTest: PropTypes.string,
answers: PropTypes.array
hypothesisTest: PropTypes.string
};
6 changes: 1 addition & 5 deletions media/js/src/simulations/simulation1/quiz.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { CriticalValue } from './criticalValue.jsx';
export const Quiz = ({
tvalue, pvalue, alpha, hypothesisTest, hypothesis,
nullHypothesis, n, completedChoices, submissionId,
plotType, isRedo, setIsRedo, setIsHypothesisCompleted,
isHypothesisCompleted, answers
plotType, isRedo, setIsRedo, setIsHypothesisCompleted, isHypothesisCompleted
}) => {
// eslint-disable-next-line max-len
const [hypothesisTest1validate, setHypothesisTest1validate] = useState(null);
Expand Down Expand Up @@ -66,7 +65,6 @@ export const Quiz = ({
hypothesisTest={hypothesisTest}
hypothesis={hypothesis}
nullHypothesis={nullHypothesis}
answers={answers}
plotType={plotType}
isRedo={isRedo}
submissionId={submissionId} />
Expand All @@ -80,7 +78,6 @@ export const Quiz = ({
hypothesis={hypothesis}
nullHypothesis={nullHypothesis}
isRedo={isRedo}
answers={answers}
n={n}
hypothesisTest2validate={hypothesisTest2validate}
setHypothesisTest2validate={setHypothesisTest2validate}
Expand Down Expand Up @@ -133,5 +130,4 @@ Quiz.propTypes = {
setIsRedo: PropTypes.func,
setIsHypothesisCompleted: PropTypes.func,
isHypothesisCompleted: PropTypes.bool,
answers: PropTypes.array
};
4 changes: 0 additions & 4 deletions media/js/src/simulations/simulation1/simulationOne.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const SimulationOne = () => {
const [completedChoices3d, setCompletedChoices3d] = useState([]);
const [selectedAltHypothesis, setSelectedAltHypothesis] = useState(null);
const [isNInvalid, setIsNInvalid] = useState(false);
const [answers, setAnswers] = useState([]);


const createSubmission = async() => {
Expand Down Expand Up @@ -160,7 +159,6 @@ export const SimulationOne = () => {
setStartQuiz2(true);
}
setSubmissionId(data.submission_id);
setAnswers(data.answers);
}
});
}, []);
Expand Down Expand Up @@ -406,7 +404,6 @@ export const SimulationOne = () => {
<SimulationOneQuiz
plotType={plotType}
coursePk={coursePk}
answers={answers}
tvalue={tvalue}
hypothesizedSlope={hypothesizedSlope}
n={N}
Expand All @@ -425,7 +422,6 @@ export const SimulationOne = () => {
<SimulationOneQuiz
plotType={plotType}
coursePk={coursePk}
answers={answers}
tvalue={tvalue3d}
hypothesizedSlope={hypothesizedSlope}
n={N}
Expand Down
88 changes: 38 additions & 50 deletions media/js/src/simulations/simulation1/simulationOneQuiz.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const SimulationOneQuiz = ({
appRvalue, tvalue, hypothesizedSlope, n, setIsCompleted,
isCompleted, submissionId, handlePlotTypeChange, plotType,
completedChoices, setCompletedChoices, selectedAltHypothesis,
setSelectedAltHypothesis, coursePk, answers
setSelectedAltHypothesis, coursePk
}) => {
const [isSubmitted, setIsSubmitted] = useState(false);
const [isTakeawayCorrect, setIsTakeawayCorrect] = useState({
Expand Down Expand Up @@ -145,56 +145,46 @@ export const SimulationOneQuiz = ({

const renderTakeawayQuestion = (
choiceKey, question, options, answer, correctFeedback,
incorrectFeedback, questionNumber) => {
const userAnswer = answers.find(
answer => answer.question_number === questionNumber);
return (
<MultipleChoiceQuestion
question={question}
header={'Takeaway'}
options={options}
answer={answer}
submissionId={submissionId}
questionNumber={questionNumber}
isSubmitted={isSubmitted}
setIsSubmitted={
(correct) => handleTakeawaySubmit(choiceKey, correct)}
questionStyle={{}}
optionStyle={{}}
answerStyle={{}}
userAnswer={userAnswer}
correctFeedback={correctFeedback}
incorrectFeedback={incorrectFeedback}
idkey={`${choiceKey}-${plotType}`}
/>
);
};
incorrectFeedback, questionNumber) => (
<MultipleChoiceQuestion
question={question}
header={'Takeaway'}
options={options}
answer={answer}
submissionId={submissionId}
questionNumber={questionNumber}
isSubmitted={isSubmitted}
setIsSubmitted={
(correct) => handleTakeawaySubmit(choiceKey, correct)}
questionStyle={{}}
optionStyle={{}}
answerStyle={{}}
correctFeedback={correctFeedback}
incorrectFeedback={incorrectFeedback}
idkey={`${choiceKey}-${plotType}`}
/>
);

const renderQualifierQuestion = (
question, options, answer, correctFeedback,
incorrectFeedback, questionNumber) => {
const userAnswer = answers.find(
answer => answer.question_number === questionNumber);
return (
<MultipleChoiceQuestion
question={question}
header={'Qualifier'}
options={options}
answer={answer}
submissionId={submissionId}
questionNumber={questionNumber}
isSubmitted={isSubmitted}
setIsSubmitted={handleQualifierSubmit}
questionStyle={{}}
optionStyle={{}}
answerStyle={{}}
userAnswer={userAnswer}
correctFeedback={correctFeedback}
incorrectFeedback={incorrectFeedback}
idkey={'qualifier'}
/>
);
};
incorrectFeedback, questionNumber) => (
<MultipleChoiceQuestion
question={question}
header={'Qualifier'}
options={options}
answer={answer}
submissionId={submissionId}
questionNumber={questionNumber}
isSubmitted={isSubmitted}
setIsSubmitted={handleQualifierSubmit}
questionStyle={{}}
optionStyle={{}}
answerStyle={{}}
correctFeedback={correctFeedback}
incorrectFeedback={incorrectFeedback}
idkey={'qualifier'}
/>
);

useEffect(() => {
isCompletedfunc();
Expand Down Expand Up @@ -283,7 +273,6 @@ export const SimulationOneQuiz = ({
isHypothesisCompleted={isHypothesisCompleted}
isRedo={isRedo}
setIsRedo={setIsRedo}
answers={answers}
/>
)}
{isHypothesisCompleted && selectedAltHypothesis === 'A'
Expand Down Expand Up @@ -624,5 +613,4 @@ SimulationOneQuiz.propTypes = {
selectedAltHypothesis: PropTypes.string,
setSelectedAltHypothesis: PropTypes.func,
coursePk: PropTypes.number.isRequired,
answers: PropTypes.array
};
Loading