Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding a Student to a 'Homeroom' now assigns the student to that home…

…room
  • Loading branch information...
commit 7cee29cc29fd94fc3873c5b1231ee4188d222c6a 1 parent 42461ea
@rnhurt authored
Showing with 11 additions and 1 deletion.
  1. +6 −0 app/controllers/courses_controller.rb
  2. +5 −1 app/models/course.rb
View
6 app/controllers/courses_controller.rb
@@ -100,6 +100,8 @@ def add_student
students.each do |student|
begin
@course.students << student
+ student.homeroom = @course.name if @course.is_homeroom?
+ student.save!
rescue ActiveRecord::RecordInvalid
# This is here to catch an existing student being added to a course
end
@@ -113,6 +115,10 @@ def add_student
if @course.students.index(@student) == nil
@course.students << @student
@course.save
+
+ # If this course is a homeroom then change this student's homeroom
+ @student.homeroom = @course.name if @course.is_homeroom?
+ @student.save!
end
end
View
6 app/models/course.rb
@@ -35,7 +35,11 @@ class Course < ActiveRecord::Base
def school_year
return self.terms.first.school_year
end
-
+
+ # Is this a "Homeroom" course?
+ def is_homeroom?
+ self.course_type.is_homeroom?
+ end
private
Please sign in to comment.
Something went wrong with that request. Please try again.