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

Update ExamSerializers according to v3 model #11674

Conversation

ozer550
Copy link
Member

@ozer550 ozer550 commented Dec 26, 2023

Summary

  • Update the serializers to validate the sections in the quiz.
  • Update usage of the Exam instances according to v3.
  • Add tests for the serializers.
  • Refactor existing tests according to new version of Exam.
  • Add Validation in the frontend for Quiz object.

References

closes #11580

Reviewer guidance

  • Change debug=true on function useQuizCreation in the code.
  • Go to Quiz section.
  • Save the quiz.
  • Exam model is created.

Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • 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')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) DEV: frontend SIZE: medium labels Dec 26, 2023
self.assertEqual(response.status_code, 400)
self.assertFalse(models.Exam.objects.filter(title=title).exists())

def test_quiz_section_with_no_resource_pool(self):
Copy link
Member Author

Choose a reason for hiding this comment

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

Was curious about the resource pool and if it's required!

Copy link
Member

@nucleogenesis nucleogenesis left a comment

Choose a reason for hiding this comment

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

One quick change requested to update a docstring -- otherwise, this all looks good to me.

With the docstring updated this can be merged.

@@ -195,8 +200,8 @@ export default function useQuizCreation(DEBUG = false) {
* @affects _channels - Calls _fetchChannels to bootstrap the list of needed channels
* Adds a new section to the quiz and sets the activeSectionID to it, preparing the module for
* use */
function initializeQuiz() {
set(_quiz, objectWithDefaults({}, Quiz));
function initializeQuiz(collection) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a @param {string} collection - The collection (aka current class ID) to associate the exam with to the doc string above here?

@ozer550 ozer550 force-pushed the update-ExamSerializer-for-question_sources branch from 123b1d0 to cb88abc Compare December 29, 2023 04:47
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

I am fairly sure that this will break horribly if we attempt to load an exam object from the database that predates the v3 model.

Did you test this scenario? It would be good to retain backend tests for that case as well to give us assurance (noting that the mapping between versions happens in the frontend).

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

I think there are still two places here where breakage will happen.

def to_representation(self, instance):
data = super().to_representation(instance)
if "question_sources" in data and data["question_sources"]:
first_question_source = data["question_sources"][0]
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this conditionality could just be done based on the data_model_version rather than this sniff test?

@ozer550 ozer550 requested a review from rtibbles January 8, 2024 06:53
@rtibbles rtibbles merged commit a5d1bbe into learningequality:develop Jan 9, 2024
@rtibbles
Copy link
Member

rtibbles commented Jan 9, 2024

Docs failure is unrelated to this PR, merging.

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.) DEV: backend Python, databases, networking, filesystem... DEV: frontend SIZE: medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants