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

fix: change teacher class API to accept Class ID instead of TeacherClass ID #1244

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

pjanik
Copy link
Member

@pjanik pjanik commented Mar 19, 2024

This PR fixes two bugs present on the Manage Classes page:
[Portal] Unable to copy a class
[Portal] Unable to sort classes

In short, the issue was that the API was designed to deal with Portal::TeacherClazz model IDs, while the client was sending Portal::Clazz IDs. It seems it should break easily, but often these IDs match - usually as long as some model instances are not deleted, or until multiple teachers are added to one class. That's why I could not reproduce this issue locally, while it was failing on staging and production.

There are two obvious solutions to this problem:
A. Change the client to use the TeacherClazz model and post these IDs to the API.
B. Change the API to use Clazz model IDs instead of TeacherClazz IDs.

I opted for option B. I think that using TeacherClazz doesn't bring any benefits, in my opinion, and it makes the API, its implementation, and the client a bit more confusing. When you copy a class, you copy a class, not a link between a teacher and a class. I could imagine that being useful only if an admin would like to copy a class on behalf of a teacher, and while copying a class, the new one should be assigned only to this specific teacher (not all owners of the previous class). But this scenario wouldn't really work with the current API, even if it were supported by the rest of the Portal.

The sorting of classes is slightly different, as in this case, we actually sort the link between the class and the teacher. But still, for client simplicity and consistency with the rest of the API, I think using the class ID is justified.

@pjanik pjanik requested a review from dougmartin March 19, 2024 14:33
Copy link
Member

@dougmartin dougmartin left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@pjanik pjanik merged commit 8ebc487 into master Mar 19, 2024
9 of 10 checks passed
@pjanik pjanik deleted the 185948944-fix-teacher-class-api branch March 19, 2024 14:50
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