-
Notifications
You must be signed in to change notification settings - Fork 365
[ Interactive Graph | Vector Graph ] PR5: Editor Support #3443
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
Changes from all commits
2148676
f16aee3
d7507b1
8619f11
77c581a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@khanacademy/perseus-editor": minor | ||
| --- | ||
|
|
||
| Creation of new Vector Graph Editor |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,11 @@ const GraphTypeSelector = (props: GraphTypeSelectorProps) => { | |
| "interactive-graph-logarithm", | ||
| ); | ||
|
|
||
| const showVector = isFeatureOn( | ||
| {apiOptions: props.apiOptions}, | ||
| "interactive-graph-vector", | ||
| ); | ||
|
|
||
| return ( | ||
| <SingleSelect | ||
| selectedValue={props.graphType} | ||
|
|
@@ -63,6 +68,7 @@ const GraphTypeSelector = (props: GraphTypeSelectorProps) => { | |
| <OptionItem value="polygon" label="Polygon" /> | ||
| <OptionItem value="segment" label="Line Segment(s)" /> | ||
| <OptionItem value="ray" label="Ray" /> | ||
| {showVector && <OptionItem value="vector" label="Vector" />} | ||
| <OptionItem value="angle" label="Angle" /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree! I wonder if we should have this be a separate ticket to discuss with content. My inclination is just to make everything alphabetical, but perhaps they would prefer a different order according to the graph types frequency of use? |
||
| </SingleSelect> | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import {components} from "@khanacademy/perseus"; | ||
| import {OptionItem, SingleSelect} from "@khanacademy/wonder-blocks-dropdown"; | ||
| import * as React from "react"; | ||
| import invariant from "tiny-invariant"; | ||
|
|
||
| import styles from "../interactive-graph-editor.module.css"; | ||
| import LabeledRow from "../locked-figures/labeled-row"; | ||
|
|
||
| import type {Props as EditorProps} from "../interactive-graph-editor"; | ||
| import type {PerseusGraphTypeVector} from "@khanacademy/perseus-core"; | ||
|
|
||
| const {InfoTip} = components; | ||
|
|
||
| interface Props { | ||
| correct: PerseusGraphTypeVector; | ||
| onChange: (props: Partial<EditorProps>) => void; | ||
| } | ||
|
|
||
| export default function VectorAnswerOptions({correct, onChange}: Props) { | ||
| return ( | ||
| <LabeledRow label="Student answer must"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is something I noticed when doing the POC yesterday in Matthew's interactive but not scored PR, the font of a label beside a dropdown is not consistent with the rest of the editor. I'm not sure if it was intentional, but in the POC i did made it consistent. I'll leave that up to you if you'll update that here, it's a trivial thing and not a blocker.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oooo I'll look into this to make sure I've implemented it how we've set up the feature previously. I was pretty sure I copied this logic exactly from the Polygon Graph, but I could have missed something! |
||
| <SingleSelect | ||
| selectedValue={correct.match || "exact"} | ||
| onChange={(newValue) => { | ||
| invariant( | ||
| correct.type === "vector", | ||
| `Expected graph type to be vector, but got ${correct.type}`, | ||
| ); | ||
| onChange({ | ||
| correct: { | ||
| ...correct, | ||
| match: newValue as PerseusGraphTypeVector["match"], | ||
| }, | ||
| }); | ||
| }} | ||
| // Never uses placeholder, always has value | ||
| placeholder="" | ||
| className={styles.singleSelectShort} | ||
| > | ||
| <OptionItem value="exact" label="match exactly" /> | ||
| <OptionItem value="congruent" label="be congruent" /> | ||
| </SingleSelect> | ||
| <InfoTip> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm less inclined to worry about this if it's a deep dive, but I'll give it a quick look to see if I can notice anything different about my implementation! :) |
||
| <p> | ||
| Congruency requires only that the vector has the same | ||
| direction and magnitude. An exact match implies congruency, | ||
| but also requires that the tail and tip are in the same | ||
| position on the grid. | ||
| </p> | ||
| </InfoTip> | ||
| </LabeledRow> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ import InteractiveGraphSettings from "./components/interactive-graph-settings"; | |
| import InteractiveGraphSRTree from "./components/interactive-graph-sr-tree"; | ||
| import PolygonAnswerOptions from "./components/polygon-answer-options"; | ||
| import SegmentCountSelector from "./components/segment-count-selector"; | ||
| import VectorAnswerOptions from "./components/vector-answer-options"; | ||
| import LabeledRow from "./locked-figures/labeled-row"; | ||
| import LockedFiguresSection from "./locked-figures/locked-figures-section"; | ||
| import StartCoordsSettings from "./start-coords/start-coords-settings"; | ||
|
|
@@ -457,6 +458,12 @@ class InteractiveGraphEditor extends React.Component<Props> { | |
| onChange={this.props.onChange} | ||
| /> | ||
| )} | ||
| {this.props.correct?.type === "vector" && ( | ||
| <VectorAnswerOptions | ||
| correct={this.props.correct} | ||
| onChange={this.props.onChange} | ||
| /> | ||
| )} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh! Yeah I fully agree, I'll update this so that it's always visible. |
||
| {this.props.correct?.type === "segment" && ( | ||
| <SegmentCountSelector | ||
| correct={this.props.correct} | ||
|
|
||





There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooopppss I think not all new graph types has editor stories 🙈
let's create a follow-up tasks for it