From ec0c8abac9b3a3064dd4f102df0fcc010cfca7cf Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 23 May 2023 15:16:15 -0400 Subject: fixed remaining errors in phys --- .../nodes/PhysicsBox/PhysicsSimulationBox.tsx | 132 +++++++++++---------- 1 file changed, 69 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx index fa47a218b..eb41e0de8 100644 --- a/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx +++ b/src/client/views/nodes/PhysicsBox/PhysicsSimulationBox.tsx @@ -66,7 +66,7 @@ interface TutorialTemplate { directionInDegrees: number; component: boolean; }[]; - show_Magnitude: boolean; + showMagnitude: boolean; }[]; } @@ -168,6 +168,16 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { let theta = this.wedgeAngle; - let index = this.dataDoc.selectedQuestion.variablesForQuestionSetup.indexOf('theta - max 45'); + let index = this.selectedQuestion.variablesForQuestionSetup.indexOf('theta - max 45'); if (index >= 0) { theta = NumListCast(this.dataDoc.questionVariables)[index]; } @@ -550,7 +556,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent(solutions); return solutions; }; @@ -558,38 +564,38 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent { 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(NumCast(this.dataDoc.review_GravityMagnitude) - this.dataDoc.selectedSolutions[i]) > epsilon) { + if (this.selectedQuestion) { + for (let i = 0; i < this.selectedQuestion.answerParts.length; i++) { + if (this.selectedQuestion.answerParts[i] == 'force of gravity') { + if (Math.abs(NumCast(this.dataDoc.review_GravityMagnitude) - this.selectedSolutions[i]) > epsilon) { error = true; } - } else if (this.dataDoc.selectedQuestion.answerParts[i] == 'angle of gravity') { - if (Math.abs(NumCast(this.dataDoc.review_GravityAngle) - this.dataDoc.selectedSolutions[i]) > epsilon) { + } else if (this.selectedQuestion.answerParts[i] == 'angle of gravity') { + if (Math.abs(NumCast(this.dataDoc.review_GravityAngle) - this.selectedSolutions[i]) > epsilon) { error = true; } - } else if (this.dataDoc.selectedQuestion.answerParts[i] == 'normal force') { - if (Math.abs(NumCast(this.dataDoc.review_NormalMagnitude) - this.dataDoc.selectedSolutions[i]) > epsilon) { + } else if (this.selectedQuestion.answerParts[i] == 'normal force') { + if (Math.abs(NumCast(this.dataDoc.review_NormalMagnitude) - this.selectedSolutions[i]) > epsilon) { error = true; } - } else if (this.dataDoc.selectedQuestion.answerParts[i] == 'angle of normal force') { - if (Math.abs(NumCast(this.dataDoc.review_NormalAngle) - this.dataDoc.selectedSolutions[i]) > epsilon) { + } else if (this.selectedQuestion.answerParts[i] == 'angle of normal force') { + if (Math.abs(NumCast(this.dataDoc.review_NormalAngle) - this.selectedSolutions[i]) > epsilon) { error = true; } - } else if (this.dataDoc.selectedQuestion.answerParts[i] == 'force of static friction') { - if (Math.abs(NumCast(this.dataDoc.review_StaticMagnitude) - this.dataDoc.selectedSolutions[i]) > epsilon) { + } else if (this.selectedQuestion.answerParts[i] == 'force of static friction') { + if (Math.abs(NumCast(this.dataDoc.review_StaticMagnitude) - this.selectedSolutions[i]) > epsilon) { error = true; } - } else if (this.dataDoc.selectedQuestion.answerParts[i] == 'angle of static friction') { - if (Math.abs(NumCast(this.dataDoc.review_StaticAngle) - this.dataDoc.selectedSolutions[i]) > epsilon) { + } else if (this.selectedQuestion.answerParts[i] == 'angle of static friction') { + if (Math.abs(NumCast(this.dataDoc.review_StaticAngle) - this.selectedSolutions[i]) > epsilon) { error = true; } - } else if (this.dataDoc.selectedQuestion.answerParts[i] == 'coefficient of static friction') { - if (Math.abs(NumCast(this.dataDoc.coefficientOfStaticFriction) - this.dataDoc.selectedSolutions[i]) > epsilon) { + } else if (this.selectedQuestion.answerParts[i] == 'coefficient of static friction') { + if (Math.abs(NumCast(this.dataDoc.coefficientOfStaticFriction) - this.selectedSolutions[i]) > epsilon) { error = true; } - } else if (this.dataDoc.selectedQuestion.answerParts[i] == 'wedge angle') { - if (Math.abs(this.wedgeAngle - this.dataDoc.selectedSolutions[i]) > epsilon) { + } else if (this.selectedQuestion.answerParts[i] == 'wedge angle') { + if (Math.abs(this.wedgeAngle - this.selectedSolutions[i]) > epsilon) { error = true; } } @@ -608,7 +614,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent(vars); - this.dataDoc.selectedQuestion = question; + this.dataDoc.selectedQuestion = JSON.stringify(question); this.dataDoc.questionPartOne = q; this.dataDoc.questionPartTwo = question.question; this.dataDoc.answers = new List(this.getAnswersToQuestion(question, vars)); @@ -1111,7 +1117,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent (this.dataDoc.hintDialogueOpen = false)}> Hints - {this.dataDoc.selectedQuestion.hints?.map((hint: any, index: number) => ( + {this.selectedQuestion.hints?.map((hint: any, index: number) => (
@@ -1136,7 +1142,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent{StrCast(this.dataDoc.questionPartTwo)}

- {this.dataDoc.selectedQuestion.answerParts.includes('force of gravity') && ( + {this.selectedQuestion.answerParts.includes('force of gravity') && ( Gravity magnitude

} lowerBound={0} @@ -1147,11 +1153,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent )} - {this.dataDoc.selectedQuestion.answerParts.includes('angle of gravity') && ( + {this.selectedQuestion.answerParts.includes('angle of gravity') && ( Gravity angle

} lowerBound={0} @@ -1163,11 +1169,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent )} - {this.dataDoc.selectedQuestion.answerParts.includes('normal force') && ( + {this.selectedQuestion.answerParts.includes('normal force') && ( Normal force magnitude

} lowerBound={0} @@ -1178,11 +1184,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent )} - {this.dataDoc.selectedQuestion.answerParts.includes('angle of normal force') && ( + {this.selectedQuestion.answerParts.includes('angle of normal force') && ( Normal force angle

} lowerBound={0} @@ -1194,11 +1200,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent )} - {this.dataDoc.selectedQuestion.answerParts.includes('force of static friction') && ( + {this.selectedQuestion.answerParts.includes('force of static friction') && ( Static friction magnitude

} lowerBound={0} @@ -1209,11 +1215,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent )} - {this.dataDoc.selectedQuestion.answerParts.includes('angle of static friction') && ( + {this.selectedQuestion.answerParts.includes('angle of static friction') && ( Static friction angle

} lowerBound={0} @@ -1225,11 +1231,11 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent )} - {this.dataDoc.selectedQuestion.answerParts.includes('coefficient of static friction') && ( + {this.selectedQuestion.answerParts.includes('coefficient of static friction') && ( @@ -1245,10 +1251,10 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent )} - {this.dataDoc.selectedQuestion.answerParts.includes('wedge angle') && ( + {this.selectedQuestion.answerParts.includes('wedge angle') && ( θ} lowerBound={0} @@ -1264,7 +1270,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent )}
@@ -1275,7 +1281,7 @@ export class PhysicsSimulationBox extends ViewBoxAnnotatableComponent

Problem

-

{this.dataDoc.tutorial.question}

+

{this.tutorial.question}

{ let step = NumCast(this.dataDoc.tutorial_stepNumber) - 1; step = Math.max(step, 0); - step = Math.min(step, this.dataDoc.tutorial.steps.length - 1); + step = Math.min(step, this.tutorial.steps.length - 1); this.dataDoc.tutorial_stepNumber = step; - this.dataDoc.mass1_forcesStart = this.dataDoc.tutorial.steps[step].forces; - this.dataDoc.mass1_forcesUpdated = this.dataDoc.tutorial.steps[step].forces; - this.dataDoc.simulation_showForceMagnitudes = this.dataDoc.tutorial.steps[step].show_Magnitude; + this.dataDoc.mass1_forcesStart = JSON.stringify(this.tutorial.steps[step].forces); + this.dataDoc.mass1_forcesUpdated = JSON.stringify(this.tutorial.steps[step].forces); + this.dataDoc.simulation_showForceMagnitudes = this.tutorial.steps[step].showMagnitude; }} disabled={this.dataDoc.tutorial_stepNumber == 0}>

- Step {NumCast(this.dataDoc.tutorial_stepNumber) + 1}: {this.dataDoc.tutorial.steps[this.dataDoc.tutorial_stepNumber].description} + Step {NumCast(this.dataDoc.tutorial_stepNumber) + 1}: {this.tutorial.steps[NumCast(this.dataDoc.tutorial_stepNumber)].description}

-

{this.dataDoc.tutorial.steps[NumCast(this.dataDoc.tutorial_stepNumber)].content}

+

{this.tutorial.steps[NumCast(this.dataDoc.tutorial_stepNumber)].content}

{ let step = NumCast(this.dataDoc.tutorial_stepNumber) + 1; step = Math.max(step, 0); - step = Math.min(step, this.dataDoc.tutorial.steps.length - 1); + step = Math.min(step, this.tutorial.steps.length - 1); this.dataDoc.tutorial_stepNumber = step; - this.dataDoc.mass1_forcesStart = this.dataDoc.tutorial.steps[step].forces; - this.dataDoc.mass1_forcesUpdated = this.dataDoc.tutorial.steps[step].forces; - this.dataDoc.simulation_showForceMagnitudes = this.dataDoc.tutorial.steps[step].show_Magnitude; + this.dataDoc.mass1_forcesStart = JSON.stringify(this.tutorial.steps[step].forces); + this.dataDoc.mass1_forcesUpdated = JSON.stringify(this.tutorial.steps[step].forces); + this.dataDoc.simulation_showForceMagnitudes = this.tutorial.steps[step].showMagnitude; }} - disabled={this.dataDoc.tutorial_stepNumber === this.dataDoc.tutorial.steps.length - 1}> + disabled={this.dataDoc.tutorial_stepNumber === this.tutorial.steps.length - 1}>
-- cgit v1.2.3-70-g09d2