Skip to content

Commit

Permalink
Finish fixing solving operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcomputerguy0101 committed Dec 15, 2022
1 parent bf2c008 commit be6e412
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions js/display/center/equationHistory.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import html from "../html.js"
import mjs from "../../mathjs/index.js"
import { EquationState } from "./equationState.js"

export class EquationHistory extends React.Component {
addState(newState, after=undefined) {
if (typeof this.props.onChange == "function") {
if (mjs.simplify(newState, mjs.expandSolvable("vl == ce").map(pattern => ({l: pattern, r: "valid()"}))).equals(mjs.parse("valid()"))) {
newState = [newState, newState.map((node, i) => i == "args[1]" ? new mjs.ConstantNode(node.evaluate()) : node)]
}

if (after == undefined) {
this.props.onChange(this.props.states.concat(newState))
} else {
Expand Down
4 changes: 3 additions & 1 deletion js/display/center/problemSpace.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export class ProblemSpace extends React.Component {
}

get constants() {
return this.props.constants.concat(this[solvedEquations])
return this.props.constants.filter(constant =>
!constant.name.equals(new mjs.SymbolNode("")) && constant.value.value != null
).concat(this[solvedEquations])
}

get equations() {
Expand Down
8 changes: 4 additions & 4 deletions js/display/overlay/helpMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export class HelpMenu extends React.Component {
image: "../steps/Step5.png",
content: "5. Continue performing operations. If you make a mistake, simply select text from a previous equation to get back on track."
},
// {
// image: "../steps/Step6.png",
// content: "6. Once an equation is solved for an unknown variable in terms of known variables, select the equals sign or the whole equation to substitute in the givens and calculate the solution."
// },
{
image: "../steps/Step6.png",
content: "6. Once an equation is solved for an unknown variable in terms of known variables, select the whole equation to substitute in the givens and calculate the solution."
},
// {
// image: "../steps/Step7.png",
// content: "7. To move on to your next problem, click the plus button within the Problems pane. Click the name of problems to switch between them."
Expand Down
2 changes: 1 addition & 1 deletion js/manipulations/subsitutionManipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SubsitutionManipulation extends Manipulation {
case "solve":
// Ensure that variable is first
const orderedSel = mjs.simplify(selection, mjs.expandSolvable("n == vl").map(pattern => ({l: pattern, r: pattern.split(" == ").reverse().join(" == ")})).concat({l: "MathQuillSelection(n)", r: "n"}))
return orderedSel.map((node, i) => i == 1 ? node.transform(node => scope.find(constant => node.equals(constant.name) && constant.valueNode.isConstantNode)?.valueNode ?? node) : node)
return orderedSel.map((node, i) => i == "args[1]" ? node.transform(node => scope.find(constant => node.equals(constant.name) && constant.valueNode.isConstantNode)?.valueNode ?? node) : node)
default:
throw new Error("Invalid subsitution mode")
}
Expand Down
Binary file added steps/Step6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit be6e412

Please sign in to comment.