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

Support multiple teachers per class #456

Open
wants to merge 31 commits into
base: main
Choose a base branch
from

Conversation

loiswells97
Copy link
Contributor

@loiswells97 loiswells97 commented Nov 1, 2024

What's Changed?

  • Added a ClassTeacher model which allows classes to have multiple teachers
  • Class model now accepts nested attributes for ClassTeachers
  • ClassMember model has been renamed to ClassStudent to provide consistency with the approach for SchoolStudent, SchoolMember etc.
  • ClassMember operations will now deal with both teachers and students in keeping with the SchoolMember module

closes #463

@cla-bot cla-bot bot added the cla-signed label Nov 1, 2024
@loiswells97 loiswells97 temporarily deployed to editor-api-p-spike-mult-xe44vc November 1, 2024 16:37 Inactive
@loiswells97 loiswells97 changed the title inconsequential change to generate pr Spike: Support multiple teachers per class Nov 1, 2024
KristinaDudnyk
KristinaDudnyk previously approved these changes Nov 8, 2024
Copy link
Contributor

@KristinaDudnyk KristinaDudnyk left a comment

Choose a reason for hiding this comment

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

Approved👍

@loiswells97 loiswells97 changed the title Spike: Support multiple teachers per class Support multiple teachers per class Feb 25, 2025
@@ -105,6 +106,10 @@ def school_owner?
school && current_user.school_owner?(school)
end

def class_teacher?(project)
project.lesson_id.present? && project.lesson.school_class.present? && project.lesson.school_class.teacher_ids.include?(current_user.id)
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need project.lesson_id.present?? I think that's implicit by project.lesson existing, since the relationship wouldn't exist otherwise

@@ -2,12 +2,15 @@

class SchoolClass < ApplicationRecord
belongs_to :school
has_many :members, class_name: :ClassMember, inverse_of: :school_class, dependent: :destroy
has_many :students, class_name: :ClassStudent, inverse_of: :school_class, dependent: :destroy
has_many :class_teachers, class_name: :ClassTeacher, inverse_of: :school_class, dependent: :destroy
Copy link
Contributor

Choose a reason for hiding this comment

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

why use :students and then :class_teachers instead of :teachers or vice versa? going with one or the other would be nice for consistency

Copy link
Contributor

@danhalson danhalson left a comment

Choose a reason for hiding this comment

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

Looks great, just a few fairly minor comments

@@ -96,11 +96,22 @@ def user_has_a_role_within_the_school
errors.add(:user, msg)
end

def user_is_a_member_or_the_owner_of_the_lesson
def user_is_class_teacher_or_student
# TODO: Revisit the case where the lesson is not associated to a class i.e. when we build a lesson library
Copy link
Contributor

Choose a reason for hiding this comment

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

think we can remove this todo now?

:name,
:created_at,
:updated_at
)

json.teacher_name(teacher&.name)
json.teachers(teachers) do |teacher|
if teacher.present?
Copy link
Contributor

Choose a reason for hiding this comment

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

there is already a _school_teacher.json.builder template you can use here and in the show template, you might just need to make the email optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix failing tests for multiple teacher support
3 participants