Skip to content

Core 675 refactor exercise preview #92

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

Merged
merged 8 commits into from
Mar 19, 2025

Conversation

jomcarvajal
Copy link
Contributor

No description provided.

@jomcarvajal jomcarvajal requested a review from jivey March 13, 2025 20:40
@jomcarvajal jomcarvajal requested a review from a team as a code owner March 13, 2025 20:40
Copy link
Member

@jivey jivey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The preview in the main Exercise story doesn't show correctness and it requires all the questionState stuff, so can you add a new set of stories for the ExercisePreview component? I'd like for people to see how they can use it by only passing in the exercise data, and optionally turning on the feedback.

@jomcarvajal jomcarvajal requested a review from jivey March 18, 2025 15:24
const { id, correct_answer_id } = answer;
return { ...acc, [id]: { ...questionStateFields, correct_answer_id } };
const questionValues = (questionStates && showAllFeedback) ? questionStates[id] : undefined;
Copy link
Member

@jivey jivey Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to make it work so that when show all feedback is true, and we don't send questionStates, that it still renders the feedback_html if it's in the exercise data? It can be a field directly on the question in the exercise: https://github.com/openstax/assessment-components/blob/main/src/types/index.ts#L10

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I removed questionStates at all. Feedback_html inside exercise(for each answer) works fine.

@jomcarvajal jomcarvajal requested a review from jivey March 18, 2025 23:00
Copy link
Member

@jivey jivey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface is much simpler now, thanks for the updates.

One final thing - with the new changes, the correct answer is no longer green, can that be restored? I see blue over here, which I think means selected:

image

Unfortunately I can't remember the right set of props to turn on that css class, it may depend on setting the correct answer id?

return {
...acc,
[id]: {
correct_answer_id: correct_answer_id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be correct_answer_id only

@jomcarvajal
Copy link
Contributor Author

The interface is much simpler now, thanks for the updates.

One final thing - with the new changes, the correct answer is no longer green, can that be restored? I see blue over here, which I think means selected:

image Unfortunately I can't remember the right set of props to turn on that css class, it may depend on setting the correct answer id?

For what I look, correct answers are green according the value of is_completed(inside questionState object). For ExercisePreview I added it as true in my last commit

@jomcarvajal jomcarvajal requested a review from jivey March 19, 2025 14:56
Copy link
Member

@jivey jivey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That did it, thank you! Can you make a new build and let @TomWoodward know about it so he can use the ExercisePreview for something he's working on?

@jomcarvajal jomcarvajal merged commit e6720bd into preview-card Mar 19, 2025
2 checks passed
@jomcarvajal jomcarvajal deleted the CORE-675-refadctor-exercise-preview branch March 19, 2025 15:10
jomcarvajal added a commit that referenced this pull request May 2, 2025
* card styles

* Overlay option added in exercise component and new component IncludeRemoveQuestion created (#86)

* overlay option added in exercise component and new component includeremovequestion created

* resolve comments

* update snapshots

* move overlay logic into Card component

* remove focus on card when overlay is up and add autoFocus for first interactive element on overlay

* Add export for IncludRemoveQuestion (#87)

add export of IncludRemoveQuestion

* Modify preview-card styles (#88)

* modify preview card styles

* change color of card when is included

* resolve comments - fix style issues

* change props in storybook of Exercise

* Add prop method for details button

* Refactor props of ExercisePreview

* export ExercisePreview

* remove focus first for screenreaders, style tweaks

* Remove aria attributes in order to read card body content (#90)

* remove aria attributes in order to read card body content

* conditional aria attributes for cardbody

* previewMode in storybook

* missing previewMode prop

* fix some type issues

* disable eslint rule for ts-ignore just for this case

* Core 675 refactor exercise preview (#92)

* remove includeRemove logic from preview exercise card

* print stories deleted by mistake

* test description fixed

* added new story for preview exercise, hide all feedback propertly

* revert print delete

* remove questionState prop, added feedback inside answers for stories purposes

* is_completed added into ExercisePreview component

* update snapshots

* New prop showCorrectAnswer (#93)

* new prop showCorrectAnswer

* fix exercise stories

* ExercisePreview now shows question detailed (#94)

* ExercisePreview now shows question detailed

* Restore print

* hide footer with new condition

* Restore print

* fix indentation in ExerciseQuestion

* set answer_id as empty

* set new margin for preview card

* update snaps

* resolve test duplicity

---------

Co-authored-by: jomcarvajal <[email protected]>
Co-authored-by: jomcarvajal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants