Skip to content
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

Enhanced Quizzes: Initial frontend state management API #11088

Conversation

nucleogenesis
Copy link
Member

Summary

Sets up foundation for state management. This introduces some "types" which can be validated much like Vue's prop validators. This is here to hopefully make clear what kinds of data we're dealing with, what functions expect to take and return, etc.

The root of this is in a new composition API module useQuizCreation which will be the source of truth for state -- which will be initialized in the quiz creation root component. The state objects and functions can then be passed around and called to wherever that root component wants.

In general, there are utilities here purpose-built for the quiz creation workflow. We can:

  • Get/set the active section and various pieces of particular data related to a section (resources, questions, title, order, etc)
  • Get/Set the order of questions for a section
  • Get the list of questions which we can use to replace a set of selected questions
  • Fetch the list of relevant contents for a particular topic ID (ie, only topics and exercises, for resource selection)

Follow up issues will hopefully be able to make use of this straight away and extend it with relative ease.

References

Closes #11012

Reviewer guidance

  1. Are there any test scenarios that aren't covered that ought to be?
  2. How does the code read -- do you feel like you'd be able to import this and get to work with it?

Testing checklist

  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')

@nucleogenesis nucleogenesis added the TODO: needs review Waiting for review label Aug 10, 2023
@github-actions github-actions bot added APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) SIZE: large labels Aug 10, 2023
Copy link
Member

@AllanOXDi AllanOXDi left a comment

Choose a reason for hiding this comment

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

@nucleogenesis, the code looks good to me, and it is well-written and easy to understand.

* @throws {Error} if section not found
* Deletes the given section by section_id */
function removeSection(section_id) {
const updatedSections = get(allSections).filter(section => section.section_id !== section_id);
Copy link
Member

Choose a reason for hiding this comment

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

This looks nice.

{ section_id: get(activeSection).section_id, question_count: newQuestionCount }
);
updateSection({
section_id: get(activeSection).section_id,
Copy link
Member

Choose a reason for hiding this comment

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

None blocking comment: you could use a more descriptive name for the variable section it is a bit too generic. It could be more descriptive if it were named something like currentSection or something along that line. I believe this would keep changing too.

@nucleogenesis nucleogenesis marked this pull request as ready for review August 23, 2023 23:08
@nucleogenesis nucleogenesis force-pushed the feature--enhanced-quizzes--11012-initial-state-management branch from 7472f7b to 19038b1 Compare August 24, 2023 15:37
Copy link
Member

@AllanOXDi AllanOXDi left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @nucleogenesis

@nucleogenesis nucleogenesis force-pushed the feature--enhanced-quizzes--11012-initial-state-management branch from 19038b1 to 3ab9f01 Compare August 25, 2023 16:55
@nucleogenesis nucleogenesis merged commit 61d87c0 into learningequality:develop Aug 25, 2023
@nucleogenesis nucleogenesis deleted the feature--enhanced-quizzes--11012-initial-state-management branch August 25, 2023 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) SIZE: large TODO: needs review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants