diff options
author | brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> | 2023-05-03 17:33:25 -0400 |
---|---|---|
committer | brynnchernosky <56202540+brynnchernosky@users.noreply.github.com> | 2023-05-03 17:33:25 -0400 |
commit | d7b4700e0a00349c2961f04f5b9d1b882cca6746 (patch) | |
tree | 0c9bd3fe26a47454498348ab78301d09bee8a338 /src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx | |
parent | 2e3df73d84228b04b8d1f284b5e18f7e48fad759 (diff) |
debug questions and tutorials
Diffstat (limited to 'src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx')
-rw-r--r-- | src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx | 866 |
1 files changed, 433 insertions, 433 deletions
diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx index 056f79368..9caf41445 100644 --- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx +++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx @@ -109,9 +109,9 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi // Used throughout sims this.layoutDoc._width = 1000; this.layoutDoc._height = 800; - this.xMax = this.layoutDoc._width*0.7; + this.xMax = this.layoutDoc._width*0.6; this.yMax = this.layoutDoc._height*0.9; - this.radius = 50; + this.radius = 100; this.dataDoc.reviewCoefficient = this.dataDoc.reviewCoefficient ?? 0; this.dataDoc.questionVariables = this.dataDoc.questionVariables ?? []; this.dataDoc.accelerationXDisplay = this.dataDoc.accelerationXDisplay ?? 0; @@ -217,9 +217,9 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi } componentDidUpdate() { - this.xMax = this.layoutDoc._width*0.7; + this.xMax = this.layoutDoc._width*0.6; this.yMax = this.layoutDoc._height*0.9; - this.radius = 0.05*this.layoutDoc._height ?? 50; + this.radius = 0.1*this.layoutDoc._height ?? 100; } setupSimulation = (simulationType: string, mode: string) => { @@ -309,75 +309,75 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi this.dataDoc.showComponentForces = (false); this.dataDoc.stepNumber = (0); this.dataDoc.showAcceleration = (false); - // if (this.dataDoc.simulationType != "Circular Motion") { - // this.dataDoc.velocityXDisplay = (0); - // this.dataDoc.velocityYDisplay = (0); - // this.dataDoc.showVelocity = (false); - // } else { - // this.dataDoc.velocityXDisplay = (20); - // this.dataDoc.velocityYDisplay = (0); - // this.dataDoc.showVelocity = (true); - // } + if (this.dataDoc.simulationType != "Circular Motion") { + this.dataDoc.velocityXDisplay = (0); + this.dataDoc.velocityYDisplay = (0); + this.dataDoc.showVelocity = (false); + } else { + this.dataDoc.velocityXDisplay = (20); + this.dataDoc.velocityYDisplay = (0); + this.dataDoc.showVelocity = (true); + } - // if (this.dataDoc.simulationType == "One Weight") { - // this.dataDoc.showForces = (true); - // this.dataDoc.startPosY = (this.yMax - 100); - // this.dataDoc.startPosX = ((this.xMax + this.xMin) / 2 - this.radius); - // this.dataDoc.selectedTutorial = (tutorials.freeWeight); - // this.dataDoc.startForces = (this.getForceFromJSON(tutorials.freeWeight.steps[0].forces)); - // this.dataDoc.showForceMagnitudes = (tutorials.freeWeight.steps[0].showMagnitude); - // } else if (this.dataDoc.simulationType == "Spring") { - // this.dataDoc.showForces = (true); - // this.setupSpring(); - // this.dataDoc.startPosY = (this.yMin + 200 + 19.62); - // this.dataDoc.startPosX = ((this.xMax + this.xMin) / 2 - this.radius); - // this.dataDoc.selectedTutorial = (tutorials.spring); - // this.dataDoc.startForces = (this.getForceFromJSON(tutorials.spring.steps[0].forces)); - // this.dataDoc.showForceMagnitudes = (tutorials.spring.steps[0].showMagnitude); - // } else if (this.dataDoc.simulationType == "Pendulum") { - // this.dataDoc.showForces = (true); - // const length = 300; - // const angle = 30; - // const x = length * Math.cos(((90 - angle) * Math.PI) / 180); - // const y = length * Math.sin(((90 - angle) * Math.PI) / 180); - // const xPos = this.xMax / 2 - x - this.radius; - // const yPos = y - this.radius - 5; - // this.dataDoc.startPosX = (xPos); - // this.dataDoc.startPosY = (yPos); - // this.dataDoc.selectedTutorial = (tutorials.pendulum); - // this.dataDoc.startForces = (this.getForceFromJSON(tutorials.pendulum.steps[0].forces)); - // this.dataDoc.showForceMagnitudes = (tutorials.pendulum.steps[0].showMagnitude); - // this.dataDoc.pendulumAngle = (30); - // this.dataDoc.pendulumLength = (300); - // this.dataDoc.adjustPendulumAngle = ({ angle: 30, length: 300 }); - // } else if (this.dataDoc.simulationType == "Inclined Plane") { - // this.dataDoc.showForces = (true); - // this.dataDoc.wedgeAngle = (26); - // this.changeWedgeBasedOnNewAngle(26); - // this.dataDoc.selectedTutorial = (tutorials.inclinePlane); - // this.dataDoc.startForces = ( - // this.getForceFromJSON(tutorials.inclinePlane.steps[0].forces) - // ); - // this.dataDoc.showForceMagnitudes = (tutorials.inclinePlane.steps[0].showMagnitude); - // } else if (this.dataDoc.simulationType == "Circular Motion") { - // this.dataDoc.showForces = (true); - // this.setupCircular(40); - // this.dataDoc.selectedTutorial = (tutorials.circular); - // this.dataDoc.startForces = (this.getForceFromJSON(tutorials.circular.steps[0].forces)); - // this.dataDoc.showForceMagnitudes = (tutorials.circular.steps[0].showMagnitude); - // } else if (this.dataDoc.simulationType == "Pulley") { - // this.dataDoc.showForces = (true); - // this.setupPulley(); - // this.dataDoc.selectedTutorial = (tutorials.pulley); - // this.dataDoc.startForces = (this.getForceFromJSON(tutorials.pulley.steps[0].forces)); - // this.dataDoc.showForceMagnitudes = (tutorials.pulley.steps[0].showMagnitude); - // } else if (this.dataDoc.simulationType == "Suspension") { - // this.dataDoc.showForces = (true); - // this.setupSuspension(); - // this.dataDoc.selectedTutorial = (tutorials.suspension); - // this.dataDoc.startForces = (this.getForceFromJSON(tutorials.suspension.steps[0].forces)); - // this.dataDoc.showForceMagnitudes = (tutorials.suspension.steps[0].showMagnitude); - // } + if (this.dataDoc.simulationType == "One Weight") { + this.dataDoc.showForces = (true); + this.dataDoc.startPosY = (this.yMax - 100); + this.dataDoc.startPosX = ((this.xMax + this.xMin) / 2 - this.radius); + this.dataDoc.selectedTutorial = (tutorials.freeWeight); + this.dataDoc.startForces = (this.getForceFromJSON(tutorials.freeWeight.steps[0].forces)); + this.dataDoc.showForceMagnitudes = (tutorials.freeWeight.steps[0].showMagnitude); + } else if (this.dataDoc.simulationType == "Spring") { + this.dataDoc.showForces = (true); + this.setupSpring(); + this.dataDoc.startPosY = (this.yMin + 200 + 19.62); + this.dataDoc.startPosX = ((this.xMax + this.xMin) / 2 - this.radius); + this.dataDoc.selectedTutorial = (tutorials.spring); + this.dataDoc.startForces = (this.getForceFromJSON(tutorials.spring.steps[0].forces)); + this.dataDoc.showForceMagnitudes = (tutorials.spring.steps[0].showMagnitude); + } else if (this.dataDoc.simulationType == "Pendulum") { + this.dataDoc.showForces = (true); + const length = 300; + const angle = 30; + const x = length * Math.cos(((90 - angle) * Math.PI) / 180); + const y = length * Math.sin(((90 - angle) * Math.PI) / 180); + const xPos = this.xMax / 2 - x - this.radius; + const yPos = y - this.radius - 5; + this.dataDoc.startPosX = (xPos); + this.dataDoc.startPosY = (yPos); + this.dataDoc.selectedTutorial = (tutorials.pendulum); + this.dataDoc.startForces = (this.getForceFromJSON(tutorials.pendulum.steps[0].forces)); + this.dataDoc.showForceMagnitudes = (tutorials.pendulum.steps[0].showMagnitude); + this.dataDoc.pendulumAngle = (30); + this.dataDoc.pendulumLength = (300); + this.dataDoc.adjustPendulumAngle = ({ angle: 30, length: 300 }); + } else if (this.dataDoc.simulationType == "Inclined Plane") { + this.dataDoc.showForces = (true); + this.dataDoc.wedgeAngle = (26); + this.changeWedgeBasedOnNewAngle(26); + this.dataDoc.selectedTutorial = (tutorials.inclinePlane); + this.dataDoc.startForces = ( + this.getForceFromJSON(tutorials.inclinePlane.steps[0].forces) + ); + this.dataDoc.showForceMagnitudes = (tutorials.inclinePlane.steps[0].showMagnitude); + } else if (this.dataDoc.simulationType == "Circular Motion") { + this.dataDoc.showForces = (true); + this.setupCircular(40); + this.dataDoc.selectedTutorial = (tutorials.circular); + this.dataDoc.startForces = (this.getForceFromJSON(tutorials.circular.steps[0].forces)); + this.dataDoc.showForceMagnitudes = (tutorials.circular.steps[0].showMagnitude); + } else if (this.dataDoc.simulationType == "Pulley") { + this.dataDoc.showForces = (true); + this.setupPulley(); + this.dataDoc.selectedTutorial = (tutorials.pulley); + this.dataDoc.startForces = (this.getForceFromJSON(tutorials.pulley.steps[0].forces)); + this.dataDoc.showForceMagnitudes = (tutorials.pulley.steps[0].showMagnitude); + } else if (this.dataDoc.simulationType == "Suspension") { + this.dataDoc.showForces = (true); + this.setupSuspension(); + this.dataDoc.selectedTutorial = (tutorials.suspension); + this.dataDoc.startForces = (this.getForceFromJSON(tutorials.suspension.steps[0].forces)); + this.dataDoc.showForceMagnitudes = (tutorials.suspension.steps[0].showMagnitude); + } this.dataDoc.simulationReset = (!this.dataDoc.simulationReset); } } @@ -541,45 +541,45 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi } }; - // // In review mode, update forces when coefficient of static friction changed - // updateReviewForcesBasedOnCoefficient = (coefficient: number) => { - // let theta: number = Number(this.dataDoc.wedgeAngle); - // let index = - // this.dataDoc.selectedQuestion.variablesForQuestionSetup.indexOf("theta - max 45"); - // if (index >= 0) { - // theta = this.dataDoc.questionVariables[index]; - // } - // if (isNaN(theta)) { - // return; - // } - // this.dataDoc.reviewGravityMagnitude = (Math.abs(this.dataDoc.gravity)); - // this.dataDoc.reviewGravityAngle = (270); - // this.dataDoc.reviewNormalMagnitude = ( - // Math.abs(this.dataDoc.gravity) * Math.cos((theta * Math.PI) / 180) - // ); - // this.dataDoc.reviewNormalAngle = (90 - theta); - // let yForce = -Math.abs(this.dataDoc.gravity); - // yForce += - // Math.abs(this.dataDoc.gravity) * - // Math.cos((theta * Math.PI) / 180) * - // Math.sin(((90 - theta) * Math.PI) / 180); - // yForce += - // coefficient * - // Math.abs(this.dataDoc.gravity) * - // Math.cos((theta * Math.PI) / 180) * - // Math.sin(((180 - theta) * Math.PI) / 180); - // let friction = - // coefficient * Math.abs(this.dataDoc.gravity) * Math.cos((theta * Math.PI) / 180); - // if (yForce > 0) { - // friction = - // (-(Math.abs(this.dataDoc.gravity) * Math.cos((theta * Math.PI) / 180)) * - // Math.sin(((90 - theta) * Math.PI) / 180) + - // Math.abs(this.dataDoc.gravity)) / - // Math.sin(((180 - theta) * Math.PI) / 180); - // } - // this.dataDoc.reviewStaticMagnitude = (friction); - // this.dataDoc.reviewStaticAngle = (180 - theta); - // }; + // In review mode, update forces when coefficient of static friction changed + updateReviewForcesBasedOnCoefficient = (coefficient: number) => { + let theta: number = Number(this.dataDoc.wedgeAngle); + let index = + this.dataDoc.selectedQuestion.variablesForQuestionSetup.indexOf("theta - max 45"); + if (index >= 0) { + theta = this.dataDoc.questionVariables[index]; + } + if (isNaN(theta)) { + return; + } + this.dataDoc.reviewGravityMagnitude = (Math.abs(this.dataDoc.gravity)); + this.dataDoc.reviewGravityAngle = (270); + this.dataDoc.reviewNormalMagnitude = ( + Math.abs(this.dataDoc.gravity) * Math.cos((theta * Math.PI) / 180) + ); + this.dataDoc.reviewNormalAngle = (90 - theta); + let yForce = -Math.abs(this.dataDoc.gravity); + yForce += + Math.abs(this.dataDoc.gravity) * + Math.cos((theta * Math.PI) / 180) * + Math.sin(((90 - theta) * Math.PI) / 180); + yForce += + coefficient * + Math.abs(this.dataDoc.gravity) * + Math.cos((theta * Math.PI) / 180) * + Math.sin(((180 - theta) * Math.PI) / 180); + let friction = + coefficient * Math.abs(this.dataDoc.gravity) * Math.cos((theta * Math.PI) / 180); + if (yForce > 0) { + friction = + (-(Math.abs(this.dataDoc.gravity) * Math.cos((theta * Math.PI) / 180)) * + Math.sin(((90 - theta) * Math.PI) / 180) + + Math.abs(this.dataDoc.gravity)) / + Math.sin(((180 - theta) * Math.PI) / 180); + } + this.dataDoc.reviewStaticMagnitude = (friction); + this.dataDoc.reviewStaticAngle = (180 - theta); + }; // In review mode, update forces when wedge angle changed updateReviewForcesBasedOnAngle = (angle: number) => { @@ -689,84 +689,84 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi return solutions; }; - // // In review mode, check if input answers match correct answers and optionally generate alert - // checkAnswers = (showAlert: boolean = true) => { - // let error: boolean = false; - // let epsilon: number = 0.01; - // if (this.dataDoc.selectedQuestion) { - // for (let i = 0; i < this.dataDoc.selectedQuestion.answerParts.length; i++) { - // if (this.dataDoc.selectedQuestion.answerParts[i] == "force of gravity") { - // if ( - // Math.abs(this.dataDoc.reviewGravityMagnitude - this.dataDoc.selectedSolutions[i]) > epsilon - // ) { - // error = true; - // } - // } else if (this.dataDoc.selectedQuestion.answerParts[i] == "angle of gravity") { - // if (Math.abs(this.dataDoc.reviewGravityAngle - this.dataDoc.selectedSolutions[i]) > epsilon) { - // error = true; - // } - // } else if (this.dataDoc.selectedQuestion.answerParts[i] == "normal force") { - // if ( - // Math.abs(this.dataDoc.reviewNormalMagnitude - this.dataDoc.selectedSolutions[i]) > epsilon - // ) { - // error = true; - // } - // } else if (this.dataDoc.selectedQuestion.answerParts[i] == "angle of normal force") { - // if (Math.abs(this.dataDoc.reviewNormalAngle - this.dataDoc.selectedSolutions[i]) > epsilon) { - // error = true; - // } - // } else if ( - // this.dataDoc.selectedQuestion.answerParts[i] == "force of static friction" - // ) { - // if ( - // Math.abs(this.dataDoc.reviewStaticMagnitude - this.dataDoc.selectedSolutions[i]) > epsilon - // ) { - // error = true; - // } - // } else if ( - // this.dataDoc.selectedQuestion.answerParts[i] == "angle of static friction" - // ) { - // if (Math.abs(this.dataDoc.reviewStaticAngle - this.dataDoc.selectedSolutions[i]) > epsilon) { - // error = true; - // } - // } else if ( - // this.dataDoc.selectedQuestion.answerParts[i] == "coefficient of static friction" - // ) { - // if ( - // Math.abs( - // Number(this.dataDoc.coefficientOfStaticFriction) - this.dataDoc.selectedSolutions[i] - // ) > epsilon - // ) { - // error = true; - // } - // } else if (this.dataDoc.selectedQuestion.answerParts[i] == "wedge angle") { - // if (Math.abs(Number(this.dataDoc.wedgeAngle) - this.dataDoc.selectedSolutions[i]) > epsilon) { - // error = true; - // } - // } - // } - // } - // if (showAlert) { - // if (!error) { - // this.dataDoc.simulationPaused = (false); - // setTimeout(() => { - // this.dataDoc.simulationPaused = (true); - // }, 3000); - // } else { - // this.dataDoc.simulationPaused = (false); - // setTimeout(() => { - // this.dataDoc.simulationPaused = (true); - // }, 3000); - // } - // } - // if (this.dataDoc.selectedQuestion.goal == "noMovement") { - // if (!error) { - // this.dataDoc.noMovement = (true); - // } else { - // this.dataDoc.roMovement = (false); - // } - // } - // }; + // In review mode, check if input answers match correct answers and optionally generate alert + checkAnswers = (showAlert: boolean = true) => { + let error: boolean = false; + let epsilon: number = 0.01; + if (this.dataDoc.selectedQuestion) { + for (let i = 0; i < this.dataDoc.selectedQuestion.answerParts.length; i++) { + if (this.dataDoc.selectedQuestion.answerParts[i] == "force of gravity") { + if ( + Math.abs(this.dataDoc.reviewGravityMagnitude - this.dataDoc.selectedSolutions[i]) > epsilon + ) { + error = true; + } + } else if (this.dataDoc.selectedQuestion.answerParts[i] == "angle of gravity") { + if (Math.abs(this.dataDoc.reviewGravityAngle - this.dataDoc.selectedSolutions[i]) > epsilon) { + error = true; + } + } else if (this.dataDoc.selectedQuestion.answerParts[i] == "normal force") { + if ( + Math.abs(this.dataDoc.reviewNormalMagnitude - this.dataDoc.selectedSolutions[i]) > epsilon + ) { + error = true; + } + } else if (this.dataDoc.selectedQuestion.answerParts[i] == "angle of normal force") { + if (Math.abs(this.dataDoc.reviewNormalAngle - this.dataDoc.selectedSolutions[i]) > epsilon) { + error = true; + } + } else if ( + this.dataDoc.selectedQuestion.answerParts[i] == "force of static friction" + ) { + if ( + Math.abs(this.dataDoc.reviewStaticMagnitude - this.dataDoc.selectedSolutions[i]) > epsilon + ) { + error = true; + } + } else if ( + this.dataDoc.selectedQuestion.answerParts[i] == "angle of static friction" + ) { + if (Math.abs(this.dataDoc.reviewStaticAngle - this.dataDoc.selectedSolutions[i]) > epsilon) { + error = true; + } + } else if ( + this.dataDoc.selectedQuestion.answerParts[i] == "coefficient of static friction" + ) { + if ( + Math.abs( + Number(this.dataDoc.coefficientOfStaticFriction) - this.dataDoc.selectedSolutions[i] + ) > epsilon + ) { + error = true; + } + } else if (this.dataDoc.selectedQuestion.answerParts[i] == "wedge angle") { + if (Math.abs(Number(this.dataDoc.wedgeAngle) - this.dataDoc.selectedSolutions[i]) > epsilon) { + error = true; + } + } + } + } + if (showAlert) { + if (!error) { + this.dataDoc.simulationPaused = (false); + setTimeout(() => { + this.dataDoc.simulationPaused = (true); + }, 3000); + } else { + this.dataDoc.simulationPaused = (false); + setTimeout(() => { + this.dataDoc.simulationPaused = (true); + }, 3000); + } + } + if (this.dataDoc.selectedQuestion.goal == "noMovement") { + if (!error) { + this.dataDoc.noMovement = (true); + } else { + this.dataDoc.roMovement = (false); + } + } + }; // Reset all review values to default resetReviewValuesToDefault = () => { @@ -781,248 +781,248 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi this.dataDoc.answerInputFields = (<div></div>); }; - // // In review mode, reset problem variables and generate a new question - // generateNewQuestion = () => { - // this.resetReviewValuesToDefault(); + // In review mode, reset problem variables and generate a new question + generateNewQuestion = () => { + this.resetReviewValuesToDefault(); - // const vars: number[] = []; - // let question: QuestionTemplate = questions.inclinePlane[0]; + const vars: number[] = []; + let question: QuestionTemplate = questions.inclinePlane[0]; - // if (this.dataDoc.simulationType == "Inclined Plane") { - // if (this.dataDoc.questionNumber == questions.inclinePlane.length - 1) { - // this.dataDoc.questionNumber = (0); - // } else { - // this.dataDoc.questionNumber =(this.dataDoc.questionNumber + 1); - // } - // question = questions.inclinePlane[this.dataDoc.questionNumber]; + if (this.dataDoc.simulationType == "Inclined Plane") { + if (this.dataDoc.questionNumber == questions.inclinePlane.length - 1) { + this.dataDoc.questionNumber = (0); + } else { + this.dataDoc.questionNumber =(this.dataDoc.questionNumber + 1); + } + question = questions.inclinePlane[this.dataDoc.questionNumber]; - // let coefficient = 0; - // let wedgeAngle = 0; + let coefficient = 0; + let wedgeAngle = 0; - // for (let i = 0; i < question.variablesForQuestionSetup.length; i++) { - // if (question.variablesForQuestionSetup[i] == "theta - max 45") { - // let randValue = Math.floor(Math.random() * 44 + 1); - // vars.push(randValue); - // wedgeAngle = randValue; - // } else if ( - // question.variablesForQuestionSetup[i] == - // "coefficient of static friction" - // ) { - // let randValue = Math.round(Math.random() * 1000) / 1000; - // vars.push(randValue); - // coefficient = randValue; - // } - // } - // this.dataDoc.wedgeAngle = (wedgeAngle); - // this.changeWedgeBasedOnNewAngle(wedgeAngle); - // this.dataDoc.coefficientOfStaticFriction = (coefficient); - // this.dataDoc.reviewCoefficient = coefficient; - // } - // let q = ""; - // for (let i = 0; i < question.questionSetup.length; i++) { - // q += question.questionSetup[i]; - // if (i != question.questionSetup.length - 1) { - // q += vars[i]; - // if (question.variablesForQuestionSetup[i].includes("theta")) { - // q += - // " degree (≈" + - // Math.round((1000 * (vars[i] * Math.PI)) / 180) / 1000 + - // " rad)"; - // } - // } - // } - // this.dataDoc.questionVariables = vars; - // this.dataDoc.selectedQuestion = (question); - // this.dataDoc.questionPartOne = (q); - // this.dataDoc.questionPartTwo = (question.question); - // const answers = this.getAnswersToQuestion(question, vars); - // this.generateInputFieldsForQuestion(false, question, answers); - // this.dataDoc.simulationReset = (!this.dataDoc.simulationReset); - // }; + for (let i = 0; i < question.variablesForQuestionSetup.length; i++) { + if (question.variablesForQuestionSetup[i] == "theta - max 45") { + let randValue = Math.floor(Math.random() * 44 + 1); + vars.push(randValue); + wedgeAngle = randValue; + } else if ( + question.variablesForQuestionSetup[i] == + "coefficient of static friction" + ) { + let randValue = Math.round(Math.random() * 1000) / 1000; + vars.push(randValue); + coefficient = randValue; + } + } + this.dataDoc.wedgeAngle = (wedgeAngle); + this.changeWedgeBasedOnNewAngle(wedgeAngle); + this.dataDoc.coefficientOfStaticFriction = (coefficient); + this.dataDoc.reviewCoefficient = coefficient; + } + let q = ""; + for (let i = 0; i < question.questionSetup.length; i++) { + q += question.questionSetup[i]; + if (i != question.questionSetup.length - 1) { + q += vars[i]; + if (question.variablesForQuestionSetup[i].includes("theta")) { + q += + " degree (≈" + + Math.round((1000 * (vars[i] * Math.PI)) / 180) / 1000 + + " rad)"; + } + } + } + this.dataDoc.questionVariables = vars; + this.dataDoc.selectedQuestion = (question); + this.dataDoc.questionPartOne = (q); + this.dataDoc.questionPartTwo = (question.question); + const answers = this.getAnswersToQuestion(question, vars); + this.generateInputFieldsForQuestion(false, question, answers); + this.dataDoc.simulationReset = (!this.dataDoc.simulationReset); + }; - // // Generate answerInputFields for new review question - // generateInputFieldsForQuestion = ( - // showIcon: boolean = false, - // question: QuestionTemplate = this.dataDoc.selectedQuestion, - // answers: number[] = this.dataDoc.selectedSolutions - // ) => { - // let answerInput = []; - // const d = new Date(); - // for (let i = 0; i < question.answerParts.length; i++) { - // if (question.answerParts[i] == "force of gravity") { - // this.dataDoc.reviewGravityMagnitude = (0); - // answerInput.push( - // <div key={i + d.getTime()}> - // <InputField - // label={<p>Gravity magnitude</p>} - // lowerBound={0} - // dataDoc={this.dataDoc} - // prop={'reviewGravityMagnitude'} - // step={0.1} - // unit={"N"} - // upperBound={50} - // value={this.dataDoc.reviewGravityMagnitude} - // showIcon={showIcon} - // correctValue={answers[i]} - // labelWidth={"7em"} - // /> - // </div> - // ); - // } else if (question.answerParts[i] == "angle of gravity") { - // this.dataDoc.reviewGravityAngle = (0); - // answerInput.push( - // <div key={i + d.getTime()}> - // <InputField - // label={<p>Gravity angle</p>} - // lowerBound={0} - // dataDoc={this.dataDoc} - // prop={'reviewGravityAngle'} - // step={1} - // unit={"°"} - // upperBound={360} - // value={this.dataDoc.reviewGravityAngle} - // radianEquivalent={true} - // showIcon={showIcon} - // correctValue={answers[i]} - // labelWidth={"7em"} - // /> - // </div> - // ); - // } else if (question.answerParts[i] == "normal force") { - // this.dataDoc.reviewNormalMagnitude = (0); - // answerInput.push( - // <div key={i + d.getTime()}> - // <InputField - // label={<p>Normal force magnitude</p>} - // lowerBound={0} - // dataDoc={this.dataDoc} - // prop={'reviewNormalMagnitude'} - // step={0.1} - // unit={"N"} - // upperBound={50} - // value={this.dataDoc.reviewNormalMagnitude} - // showIcon={showIcon} - // correctValue={answers[i]} - // labelWidth={"7em"} - // /> - // </div> - // ); - // } else if (question.answerParts[i] == "angle of normal force") { - // this.dataDoc.reviewNormalAngle = (0); - // answerInput.push( - // <div key={i + d.getTime()}> - // <InputField - // label={<p>Normal force angle</p>} - // lowerBound={0} - // dataDoc={this.dataDoc} - // prop={'reviewNormalAngle'} - // step={1} - // unit={"°"} - // upperBound={360} - // value={this.dataDoc.reviewNormalAngle} - // radianEquivalent={true} - // showIcon={showIcon} - // correctValue={answers[i]} - // labelWidth={"7em"} - // /> - // </div> - // ); - // } else if (question.answerParts[i] == "force of static friction") { - // this.dataDoc.reviewStaticMagnitude = (0); - // answerInput.push( - // <div key={i + d.getTime()}> - // <InputField - // label={<p>Static friction magnitude</p>} - // lowerBound={0} - // dataDoc={this.dataDoc} - // prop={'reviewStaticMagnitude'} - // step={0.1} - // unit={"N"} - // upperBound={50} - // value={this.dataDoc.reviewStaticMagnitude} - // showIcon={showIcon} - // correctValue={answers[i]} - // labelWidth={"7em"} - // /> - // </div> - // ); - // } else if (question.answerParts[i] == "angle of static friction") { - // this.dataDoc.reviewStaticAngle = (0); - // answerInput.push( - // <div key={i + d.getTime()}> - // <InputField - // label={<p>Static friction angle</p>} - // lowerBound={0} - // dataDoc={this.dataDoc} - // prop={'reviewStaticAngle'} - // step={1} - // unit={"°"} - // upperBound={360} - // value={this.dataDoc.reviewStaticAngle} - // radianEquivalent={true} - // showIcon={showIcon} - // correctValue={answers[i]} - // labelWidth={"7em"} - // /> - // </div> - // ); - // } else if (question.answerParts[i] == "coefficient of static friction") { - // this.updateReviewForcesBasedOnCoefficient(0); - // answerInput.push( - // <div key={i + d.getTime()}> - // <InputField - // label={ - // <Box> - // μ<sub>s</sub> - // </Box> - // } - // lowerBound={0} - // dataDoc={this.dataDoc} - // prop={'coefficientOfStaticFriction'} - // step={0.1} - // unit={""} - // upperBound={1} - // value={this.dataDoc.coefficientOfStaticFriction} - // effect={this.updateReviewForcesBasedOnCoefficient} - // showIcon={showIcon} - // correctValue={answers[i]} - // /> - // </div> - // ); - // } else if (question.answerParts[i] == "wedge angle") { - // this.updateReviewForcesBasedOnAngle(0); - // answerInput.push( - // <div key={i + d.getTime()}> - // <InputField - // label={<Box>θ</Box>} - // lowerBound={0} - // dataDoc={this.dataDoc} - // prop={'wedgeAngle'} - // step={1} - // unit={"°"} - // upperBound={49} - // value={this.dataDoc.wedgeAngle} - // effect={(val: number) => { - // this.changeWedgeBasedOnNewAngle(val); - // this.updateReviewForcesBasedOnAngle(val); - // }} - // radianEquivalent={true} - // showIcon={showIcon} - // correctValue={answers[i]} - // /> - // </div> - // ); - // } - // } + // Generate answerInputFields for new review question + generateInputFieldsForQuestion = ( + showIcon: boolean = false, + question: QuestionTemplate = this.dataDoc.selectedQuestion, + answers: number[] = this.dataDoc.selectedSolutions + ) => { + let answerInput = []; + const d = new Date(); + for (let i = 0; i < question.answerParts.length; i++) { + if (question.answerParts[i] == "force of gravity") { + this.dataDoc.reviewGravityMagnitude = (0); + answerInput.push( + <div key={i + d.getTime()}> + <InputField + label={<p>Gravity magnitude</p>} + lowerBound={0} + dataDoc={this.dataDoc} + prop={'reviewGravityMagnitude'} + step={0.1} + unit={"N"} + upperBound={50} + value={this.dataDoc.reviewGravityMagnitude} + showIcon={showIcon} + correctValue={answers[i]} + labelWidth={"7em"} + /> + </div> + ); + } else if (question.answerParts[i] == "angle of gravity") { + this.dataDoc.reviewGravityAngle = (0); + answerInput.push( + <div key={i + d.getTime()}> + <InputField + label={<p>Gravity angle</p>} + lowerBound={0} + dataDoc={this.dataDoc} + prop={'reviewGravityAngle'} + step={1} + unit={"°"} + upperBound={360} + value={this.dataDoc.reviewGravityAngle} + radianEquivalent={true} + showIcon={showIcon} + correctValue={answers[i]} + labelWidth={"7em"} + /> + </div> + ); + } else if (question.answerParts[i] == "normal force") { + this.dataDoc.reviewNormalMagnitude = (0); + answerInput.push( + <div key={i + d.getTime()}> + <InputField + label={<p>Normal force magnitude</p>} + lowerBound={0} + dataDoc={this.dataDoc} + prop={'reviewNormalMagnitude'} + step={0.1} + unit={"N"} + upperBound={50} + value={this.dataDoc.reviewNormalMagnitude} + showIcon={showIcon} + correctValue={answers[i]} + labelWidth={"7em"} + /> + </div> + ); + } else if (question.answerParts[i] == "angle of normal force") { + this.dataDoc.reviewNormalAngle = (0); + answerInput.push( + <div key={i + d.getTime()}> + <InputField + label={<p>Normal force angle</p>} + lowerBound={0} + dataDoc={this.dataDoc} + prop={'reviewNormalAngle'} + step={1} + unit={"°"} + upperBound={360} + value={this.dataDoc.reviewNormalAngle} + radianEquivalent={true} + showIcon={showIcon} + correctValue={answers[i]} + labelWidth={"7em"} + /> + </div> + ); + } else if (question.answerParts[i] == "force of static friction") { + this.dataDoc.reviewStaticMagnitude = (0); + answerInput.push( + <div key={i + d.getTime()}> + <InputField + label={<p>Static friction magnitude</p>} + lowerBound={0} + dataDoc={this.dataDoc} + prop={'reviewStaticMagnitude'} + step={0.1} + unit={"N"} + upperBound={50} + value={this.dataDoc.reviewStaticMagnitude} + showIcon={showIcon} + correctValue={answers[i]} + labelWidth={"7em"} + /> + </div> + ); + } else if (question.answerParts[i] == "angle of static friction") { + this.dataDoc.reviewStaticAngle = (0); + answerInput.push( + <div key={i + d.getTime()}> + <InputField + label={<p>Static friction angle</p>} + lowerBound={0} + dataDoc={this.dataDoc} + prop={'reviewStaticAngle'} + step={1} + unit={"°"} + upperBound={360} + value={this.dataDoc.reviewStaticAngle} + radianEquivalent={true} + showIcon={showIcon} + correctValue={answers[i]} + labelWidth={"7em"} + /> + </div> + ); + } else if (question.answerParts[i] == "coefficient of static friction") { + this.updateReviewForcesBasedOnCoefficient(0); + answerInput.push( + <div key={i + d.getTime()}> + <InputField + label={ + <Box> + μ<sub>s</sub> + </Box> + } + lowerBound={0} + dataDoc={this.dataDoc} + prop={'coefficientOfStaticFriction'} + step={0.1} + unit={""} + upperBound={1} + value={this.dataDoc.coefficientOfStaticFriction} + effect={this.updateReviewForcesBasedOnCoefficient} + showIcon={showIcon} + correctValue={answers[i]} + /> + </div> + ); + } else if (question.answerParts[i] == "wedge angle") { + this.updateReviewForcesBasedOnAngle(0); + answerInput.push( + <div key={i + d.getTime()}> + <InputField + label={<Box>θ</Box>} + lowerBound={0} + dataDoc={this.dataDoc} + prop={'wedgeAngle'} + step={1} + unit={"°"} + upperBound={49} + value={this.dataDoc.wedgeAngle} + effect={(val: number) => { + this.changeWedgeBasedOnNewAngle(val); + this.updateReviewForcesBasedOnAngle(val); + }} + radianEquivalent={true} + showIcon={showIcon} + correctValue={answers[i]} + /> + </div> + ); + } + } - // this.dataDoc.answerInputFields = ( - // <div - // style={{ display: "flex", flexDirection: "column", alignItems: "left" }} - // > - // {answerInput} - // </div> - // ); - // }; + this.dataDoc.answerInputFields = ( + <div + style={{ display: "flex", flexDirection: "column", alignItems: "left" }} + > + {answerInput} + </div> + ); + }; // Default setup for uniform circular motion simulation setupCircular = (value: number) => { @@ -1465,7 +1465,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi </select> </div> </div> - {/* {this.dataDoc.mode == "Review" && this.dataDoc.simulationType != "Inclined Plane" && ( + {this.dataDoc.mode == "Review" && this.dataDoc.simulationType != "Inclined Plane" && ( <div className="wordProblemBox"> <p>{this.dataDoc.simulationType} review problems in progress!</p> </div> @@ -1479,8 +1479,8 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi }} sx={{ position: "fixed", - left: xMax - 50 + "px", - top: yMin + 14 + "px", + left: this.xMax - 50 + "px", + top: this.yMin + 14 + "px", }} > <QuestionMarkIcon /> @@ -1529,8 +1529,8 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi <div className="answer">{this.dataDoc.answerInputFields}</div> </div> </div> - )} */} - {/* {this.dataDoc.mode == "Tutorial" && ( + )} + {this.dataDoc.mode == "Tutorial" && ( <div className="wordProblemBox"> <div className="question"> <h2>Problem</h2> @@ -1674,8 +1674,8 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi )} </div> </div> - )} */} - {/* {this.dataDoc.mode == "Review" && this.dataDoc.simulationType == "Inclined Plane" && ( + )} + {this.dataDoc.mode == "Review" && this.dataDoc.simulationType == "Inclined Plane" && ( <div style={{ display: "flex", @@ -1713,7 +1713,7 @@ export default class PhysicsSimulationBox extends ViewBoxAnnotatableComponent<Fi </Button> </div> </div> - )} */} + )} {this.dataDoc.mode == "Freeform" && ( <div className="vars"> <FormControl component="fieldset"> |