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

Migrate fields/functionality from Quiz to Assignment #32

Merged
merged 3 commits into from
May 27, 2024

Conversation

krishnans2006
Copy link
Member

This improves general model relationships and paves the way for future quiz improvements (like #9).

It also renames LogMessage to QuizLogMessage to both clear existing log messages and make the name more readable.

Also rename LogMessage to QuizLogMessage
@krishnans2006 krishnans2006 self-assigned this May 27, 2024
@krishnans2006 krishnans2006 requested a review from a team as a code owner May 27, 2024 05:08
@krishnans2006
Copy link
Member Author

Here's a script that successfully migrates assignments to the new structure:

from tin.apps.assignment.models import Assignment, Quiz

for assignment in Assignment.objects.all():
    if Quiz.objects.filter(assignment=assignment).exists():
        q = Quiz.objects.filter(assignment=assignment)[0]
        assignment.is_quiz = True
        assignment.quiz_action = q.action
        assignment.save()
        print("*", end="")

Copy link
Member

@JasonGrace2282 JasonGrace2282 left a comment

Choose a reason for hiding this comment

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

Overall, looks good to me!
Left some comments, but could you also add the ability to enable/disable autocomplete on quizzes?

tin/apps/assignments/models.py Outdated Show resolved Hide resolved
tin/apps/assignments/tests.py Show resolved Hide resolved
@krishnans2006
Copy link
Member Author

could you also add the ability to enable/disable autocomplete on quizzes?

I meant for this PR to just be a one-to-one migration, without adding new features; I'd like to make sure that everything is set up properly first. So, autocomplete will probably be in a follow-up commit/PR (along with #9 and other planned improvements).

@krishnans2006 krishnans2006 merged commit 9c7f97f into master May 27, 2024
6 checks passed
@krishnans2006
Copy link
Member Author

Update: the code snippet above had a typo. For documentation purposes, here's the code that was run on production:

from tin.apps.assignments.models import Assignment, Quiz

for assignment in Assignment.objects.all():
    if Quiz.objects.filter(assignment=assignment).exists():
        q = Quiz.objects.filter(assignment=assignment)[0]
        assignment.is_quiz = True
        assignment.quiz_action = q.action
        assignment.save()
        print("*", end="")

The output was

*****************************************************************************************************************************

meaning 125 assignments were changed. 🎉

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