-
Notifications
You must be signed in to change notification settings - Fork 350
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
Add "static" toggle to Interactive Graph widget #1503
Conversation
GeraldRequired Reviewers
Don't want to be involved in this pull request? Comment |
npm Snapshot: PublishedGood news!! We've packaged up the latest commit from this PR (d15fa13) and published it to npm. You Example: yarn add @khanacademy/perseus@PR1503 If you are working in Khan Academy's webapp, you can run: ./dev/tools/bump_perseus_version.sh -t PR1503 |
Size Change: +45 B (+0.01%) Total Size: 855 kB
ℹ️ View Unchanged
|
Haven't finished properly reviewing, but I believe some of this code is code I also changed in my bug fix PR. It's been approved, but I wanted to manually test before landing. Hoping to do that today, just ran into some local dev server / ZND issues. I'll totally update my PR if this one moves forward first though :) |
@Myranae I'll wait for you to land your PR. I need to test this on a ZND before landing it anyway. |
@benchristel It's landed :) |
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.
Cool. I was initially surprised by the size of the PR (number of files touched) but most of that is removing hintMode
. I'm pretty happy we can use static
mode and not introduce another new concept (assuming it all works out). Thanks Ben!
@@ -45,11 +45,11 @@ export type MafsGraphProps = { | |||
labels: InteractiveGraphProps["labels"]; | |||
state: InteractiveGraphState; | |||
dispatch: React.Dispatch<InteractiveGraphAction>; | |||
hintMode: boolean; | |||
static: boolean | null | undefined; |
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.
I'm not sure if types from other uses of static
force this, but can we make this static: boolean | undefined
? I think there are many places that use this X | null | undefined
pattern, but in reality, we rarely distinguish between null
and undefined
.
This is a nitpicky thing, but it's another place where the type is broader/more complicated for no reason.
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.
The type boolean | null | undefined
comes from WidgetProps, so I had to use the same type here.
I don't really feel comfortable changing WidgetProps, since it's so widely used (and it's one of our few defenses against writing widgets that can't handle production data).
// The name isStatic (instead of static) avoids a collision with the | ||
// `static` keyword in ES6. `static` is not a valid variable name, so | ||
// naming this `isStatic` allows the object to be destructured without | ||
// renaming the resulting variables. | ||
isStatic: boolean; |
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.
Guess we'll want to avoid having a Perseus concept named "const" then, eh? 😂
3e33577
to
81db6a7
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1503 +/- ##
==========================================
+ Coverage 70.00% 70.61% +0.61%
==========================================
Files 514 517 +3
Lines 106133 106174 +41
Branches 7629 10875 +3246
==========================================
+ Hits 74296 74974 +678
+ Misses 31720 31200 -520
+ Partials 117 0 -117
... and 125 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Doing some manual testing on this, I noticed the hints-renderer stories related to interactive graph hint mode don't work anymore because hint mode isn't a thing and graphs don't automatically become static when added as a hint. As a result, we may want to delete all the interactive graph stories from the Hints Renderer stories section, especially since we now have static graph stories instead. This story and all the interactive graph ones under it I mean. |
@jeremywiebe @Myranae I realized I missed a crucial part of this feature, which is displaying the correct answer instead of the start coords when the graph is in static mode. So I'll have to ask for another review. I'd really like Nicole's eyes on this when she's well again, because I suspect she's already done the research to figure out how displaying the correct answer is supposed to work. I've got a solution, but I'm not sure it follows established patterns. |
c3f51a8
to
02985f3
Compare
This reverts commit 83bebcf.
02985f3
to
0f2821e
Compare
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.
This is great. LGTM!
@@ -1352,30 +1352,6 @@ describe("renderer", () => { | |||
expect(el).not.toBeNull(); | |||
}); | |||
|
|||
it("should force the widget to be non-static if it has a problem number", () => { |
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.
Really glad we don't need to further commit to this hack. 😅
.build(); | ||
result["widgets"] = { | ||
...result["widgets"], | ||
"radio 1": { |
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.
Hrm... seems like we now we need a radioQuestionBuilder()
😃
@@ -128,5 +129,15 @@ export const StatefulMafsGraph = React.forwardRef< | |||
graph.startCoords, | |||
]); | |||
|
|||
if (props.static) { |
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.
This becomes obvious fairly quickly as I read the code, but could you leave a comment here that if we're in static
mode we display the correct answer? (unless you don't feel that's necessary)
Summary:
Some of our widgets (e.g. Radio) have a "static" mode which can be toggled on
in the exercise editor. When a widget is in static mode, the "answer" to the
widget is displayed, the widget is not graded, and the learner cannot alter
the widget's state.
Content creators need to be able to set interactive graphs to static mode so
that graphs can be added to hints, to demonstrate the solution steps for an
exercise. Previously, we implemented a special "hint mode" for interactive
graphs to accommodate this use case. Hint mode was based on a couple faulty
assumptions:
We confused static mode with the "read only" state of a widget, which occurs
when a learner has successfully answered the question. Similar to static mode,
the read-only state makes the widget non-interactable. However, while static
mode is configurable by content creators, read-only state is not; it is set
or unset dynamically, based on the learner's progress through an exercise.
turned on hint mode automatically in hints (and turned it off in question
stems) rather than giving content creators a manual toggle. This assumption
turned out to be incorrect; we now know of at least one question where a hint
contains a graph that the learner is supposed to be able to manipulate. See:
https://khanacademy.slack.com/archives/C067UM1QAR4/p1723045477082029
Hint mode (which this feature replaces) was never released to content creators,
so we are okay to drop support for it.
This PR removes hint mode and adds a "static" toggle to the Interactive
Graph widget editor. It builds on work that @nicolecomputer did in
#1457. Her feature branch is merged into
this one.
Issue: LEMS-2251, LEMS-2053, LEMS-2054
Test plan:
the "static" toggle is on, and interactable when "static" is off.
the static graphs.
graded.