diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 3fffad624..86acf122c 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -160,6 +160,10 @@ def update
@course.configured_by_user_id = current_user.id
end
+ if (params[:teaching_assistants])
+ params[:course][:teaching_assistant_assignments_override] = params[:teaching_assistants]
+ end
+
params[:course][:faculty_assignments_override] = params[:teachers]
respond_to do |format|
@course.updated_by_user_id = current_user.id if current_user
diff --git a/app/controllers/deliverables_controller.rb b/app/controllers/deliverables_controller.rb
index f8d95b243..e0bd748cd 100644
--- a/app/controllers/deliverables_controller.rb
+++ b/app/controllers/deliverables_controller.rb
@@ -33,7 +33,7 @@ def grading_queue_for_course
# @assignments = Assignment.where(:course_id => @course.id).all.sort_by(&:task_number)
- if @course.faculty.include?(current_user)
+ if @course.faculty_and_teaching_assistants.include?(current_user)
# Get all deliverables for this team/student
@deliverables = Deliverable.get_deliverables(params[:course_id], current_user.id, {:is_my_team => 1})
@@ -58,7 +58,7 @@ def get_deliverables
#temporary for mel
def team_index_for_course
@course = Course.find(params[:course_id])
- if (current_user.is_admin? || @course.faculty.include?(current_user))
+ if (current_user.is_admin? || @course.faculty_and_teaching_assistants.include?(current_user))
@deliverables = Deliverable.where("team_id is not null").find_all_by_course_id(@course.id)
else
has_permissions_or_redirect(:admin, root_path)
@@ -68,7 +68,7 @@ def team_index_for_course
#temporary for mel
def individual_index_for_course
@course = Course.find(params[:course_id])
- if (current_user.is_admin? || @course.faculty.include?(current_user))
+ if (current_user.is_admin? || @course.faculty_and_teaching_assistants.include?(current_user))
@deliverables = Deliverable.where("team_id is null").find_all_by_course_id(@course.id)
else
has_permissions_or_redirect(:admin, root_path)
@@ -107,7 +107,7 @@ def show
redirect_to root_path and return
end
- if (current_user.is_admin? || @course.faculty.include?(current_user))
+ if (current_user.is_admin? || @course.faculty_and_teaching_assistants.include?(current_user))
if @course.grading_rule.nil?
flash[:error] = I18n.t(:no_grading_rule_for_course)
redirect_to course_path(@course) and return
@@ -118,7 +118,7 @@ def show
end
respond_to do |format|
- if (current_user.is_admin? || @course.faculty.include?(current_user))
+ if (current_user.is_admin? || @course.faculty_and_teaching_assistants.include?(current_user))
format.html { render layout: false }
else
format.html # show.html.erb
@@ -281,7 +281,7 @@ def edit_feedback
@deliverable = Deliverable.find(params[:id])
-# if !@deliverable.assignment.course.faculty.include?(current_user)
+# if !@deliverable.assignment.course.faculty_and_teaching_assistants.include?(current_user)
# flash[:error] = "Only faculty teaching this course can provide feedback on deliverables. #{current_user.human_name}"
# redirect_to :controller => "welcome", :action => "index"
# return
@@ -292,7 +292,7 @@ def edit_feedback
def update_feedback
@deliverable = Deliverable.find(params[:id])
- unless (current_user.is_admin? || @deliverable.course.faculty.include?(current_user))
+ unless (current_user.is_admin? || @deliverable.course.faculty_and_teaching_assistants.include?(current_user))
flash[:error] = I18n.t(:not_your_deliverable)
redirect_to root_path and return
end
diff --git a/app/controllers/grades_controller.rb b/app/controllers/grades_controller.rb
index 9e3cad4be..ef79c6133 100644
--- a/app/controllers/grades_controller.rb
+++ b/app/controllers/grades_controller.rb
@@ -18,7 +18,7 @@ def render_grade_book_menu
end
def validate_permission
- unless (current_user.is_admin? || @course.faculty.include?(current_user))
+ unless (current_user.is_admin? || @course.faculty_and_teaching_assistants.include?(current_user))
has_permissions_or_redirect(:admin, root_path)
end
end
@@ -58,7 +58,7 @@ def student_deliverables_and_grades_for_course
@user = current_user
end
if (current_user.id != @user.id)
- unless (@course.faculty.include?(current_user))||(current_user.is_admin?)
+ unless (@course.faculty_and_teaching_assistants.include?(current_user))||(current_user.is_admin?)
flash[:error] = I18n.t(:not_your_deliverable)
redirect_to root_path and return
end
diff --git a/app/controllers/presentations_controller.rb b/app/controllers/presentations_controller.rb
index 39b131bbd..cb0e5dc18 100644
--- a/app/controllers/presentations_controller.rb
+++ b/app/controllers/presentations_controller.rb
@@ -41,7 +41,7 @@ def index
# GET /courses/:course_id/presentations
def index_for_course
@course = Course.find(params[:course_id])
- if (current_user.is_admin? || @course.faculty.include?(current_user))
+ if (current_user.is_admin? || @course.faculty_and_teaching_assistants.include?(current_user))
@presentations = Presentation.find_all_by_course_id(@course.id)
else
has_permissions_or_redirect(:admin, root_path)
@@ -51,7 +51,7 @@ def index_for_course
# GET /course/:person_id/presentations/new
def new
@course = Course.find(params[:course_id])
- if (current_person.is_admin? || @course.faculty.include?(current_user))
+ if (current_person.is_admin? || @course.faculty_and_teaching_assistants.include?(current_user))
@presentation = Presentation.new(:presentation_date => Date.today)
@course =Course.find_by_id(params[:course_id])
else
@@ -62,7 +62,7 @@ def new
# GET /course/:person_id/presentations/:id/edit
#def edit
# @presentation = Presentation.find(:course_id)
- # if (current_person.is_admin? || @course.faculty.include?(current_user))
+ # if (current_person.is_admin? || @course.faculty_and_teaching_assistants.include?(current_user))
# @presentation = Presentation.new(:presentation_date => Date.today)
# @course =Course.find_by_id(params[:course_id])
# else
diff --git a/app/models/course.rb b/app/models/course.rb
index e44b580be..4dfa3a0f7 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -42,6 +42,9 @@ class Course < ActiveRecord::Base
has_many :faculty_assignments
has_many :faculty, :through => :faculty_assignments, :source => :user
+ has_many :teaching_assistant_assignments
+ has_many :teaching_assistants, :through => :teaching_assistant_assignments, :source => :user
+
has_many :registrations
has_many :registered_students, :through => :registrations, :source => :user
@@ -55,6 +58,7 @@ class Course < ActiveRecord::Base
validates_presence_of :semester, :year, :mini, :name
validate :validate_faculty_assignments
+ validate :validate_teaching_assistant_assignments
versioned
belongs_to :updated_by, :class_name => 'User', :foreign_key => 'updated_by_user_id'
@@ -65,10 +69,16 @@ class Course < ActiveRecord::Base
# that they are people in the system) and then to save the people in the faculty association.
attr_accessor :faculty_assignments_override
+ #When assigning teaching_assistant to a page, the user types in a series of strings that then need to be processed
+ # :teaching_assistant_assignments_override is a temporary variable that is used to do validation of the strings (to verify
+ # that they are people in the system) and then to save the people in the teaching_assistant association.
+ attr_accessor :teaching_assistant_assignments_override
+
attr_accessible :course_number_id, :name, :number, :semester, :mini, :primary_faculty_label,
:secondary_faculty_label, :twiki_url, :remind_about_effort, :short_name, :year,
:peer_evaluation_first_email, :peer_evaluation_second_email,
:curriculum_url, :configure_course_twiki,
+ :teaching_assistant_assignments_override,
:faculty_assignments_override
include PeopleInACollection
@@ -77,6 +87,10 @@ def validate_faculty_assignments
validate_members :faculty_assignments_override
end
+ def validate_teaching_assistant_assignments
+ validate_members :teaching_assistant_assignments_override
+ end
+
# def to_param
# display_course_name
# end
@@ -120,7 +134,7 @@ def display_semester
end
#before_validation :set_updated_by_user -- this needs to be done by the controller
- before_save :strip_whitespaces, :update_email_address, :need_to_update_google_list?, :update_faculty
+ before_save :strip_whitespaces, :update_email_address, :need_to_update_google_list?, :update_teaching_assistants, :update_faculty
after_save :update_distribution_list
scope :unique_course_numbers_and_names_by_number, :select => "DISTINCT number, name", :order => 'number ASC'
@@ -235,6 +249,20 @@ def update_faculty
self.updating_email = true
end
+ #When modifying validate_teaching_assistant or update_teaching_assistant, modify the same code in team.rb
+ #Todo - move to a higher class or try as a mixin
+ def update_teaching_assistants
+ return "" if teaching_assistant_assignments_override.nil?
+ self.teaching_assistants = []
+
+ self.teaching_assistant_assignments_override = teaching_assistant_assignments_override.select { |name| name != nil && name.strip != "" }
+ list = map_member_strings_to_users(self.teaching_assistant_assignments_override)
+ raise "Error converting teaching_assistant_assignments_override to IDs!" if list.include?(nil)
+ self.teaching_assistants = list
+ teaching_assistant_assignments_override = nil
+ self.updating_email = true
+ end
+
def copy_as_new_course
new_course = self.dup
new_course.is_configured = false
@@ -244,6 +272,7 @@ def copy_as_new_course
new_course.updated_at = Time.now
new_course.curriculum_url = nil if self.curriculum_url.nil? || self.curriculum_url.include?("twiki")
new_course.faculty = self.faculty
+ new_course.teaching_assistants = self.teaching_assistants
new_course.grading_rule = self.grading_rule.dup if self.grading_rule.present?
self.assignments.each { |assignment| new_course.assignments << assignment.dup } if self.assignments.present?
return new_course
@@ -363,6 +392,11 @@ def copy_pages_to_another_course(destination_course_id, url_prefix)
end
public
+
+ def faculty_and_teaching_assistants
+ faculty + teaching_assistants
+ end
+
def registered_students_and_students_on_teams_hash
students = Hash.new
self.registered_students.each do |student|
diff --git a/app/models/deliverable.rb b/app/models/deliverable.rb
index f9db50464..3730543c0 100644
--- a/app/models/deliverable.rb
+++ b/app/models/deliverable.rb
@@ -300,7 +300,7 @@ def send_deliverable_feedback_email(url, faculty_email=nil)
# To check if the current user can change/edit the deliverable
def editable?(current_user)
- return true if self.course.faculty.include?(current_user)
+ return true if self.course.faculty_and_teaching_assistants.include?(current_user)
if self.is_team_deliverable?
unless self.team.is_user_on_team?(current_user)
diff --git a/app/models/teaching_assistant_assignment.rb b/app/models/teaching_assistant_assignment.rb
new file mode 100644
index 000000000..9be1cc8df
--- /dev/null
+++ b/app/models/teaching_assistant_assignment.rb
@@ -0,0 +1,5 @@
+class TeachingAssistantAssignment < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :course
+
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index 9194f7473..d8d714ddf 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -27,6 +27,9 @@ class User < ActiveRecord::Base
has_many :faculty_assignments
has_many :teaching_these_courses, :through => :faculty_assignments, :source => :course
+ has_many :teaching_assistant_assignments
+ has_many :teacher_assisting_these_courses, :through => :teaching_assistant_assignments, :source => :course
+
has_many :team_assignments
has_many :teams, :through => :team_assignments, :source => :team
@@ -104,6 +107,9 @@ def self.find_by_param(param)
end
end
+ def teacher_assisting_these_courses_during_current_semester
+ teacher_assisting_these_courses.where(:semester => AcademicCalendar.current_semester, :year => Date.today.year)
+ end
def teaching_these_courses_during_current_semester
teaching_these_courses.where(:semester => AcademicCalendar.current_semester, :year => Date.today.year)
diff --git a/app/views/courses/_form_create.erb b/app/views/courses/_form_create.erb
index 3bcfc27ce..26be42885 100644
--- a/app/views/courses/_form_create.erb
+++ b/app/views/courses/_form_create.erb
@@ -48,6 +48,19 @@
+
+
Teaching Assistants for this course
+ They will be notified of the assignment
+
+ <% if @course.teaching_assistant_assignments_override.nil? %>
+ <%= render :partial => '/people/person_in_a_collection', :collection => @course.teaching_assistants.map(&:human_name), :as => :person, :locals => {:collection_form => f, :member_label => "Teaching Assistant"} %>
+ <% else %>
+ <%= render :partial => '/people/person_in_a_collection', :collection => @course.teaching_assistant_assignments_override, :as => :person, :locals => {:collection_form => f, :member_label => "Teaching Assistant"} %>
+ <% end %>
+
+
+
+
<%# content_for :javascript do %>
<%# javascript_tag do %>
<%# end %>
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb
index d91ac6e0e..4bcda5027 100644
--- a/app/views/courses/show.html.erb
+++ b/app/views/courses/show.html.erb
@@ -35,6 +35,16 @@
<% end %>
+ <% if not @course.teaching_assistants.empty? %>
+
+ | Teaching Assistants: |
+
+ <% @course.teaching_assistants.each do |teaching_assitant| %>
+ <%= link_to teaching_assistant.human_name, user_path(teaching_assistant) %>
+ <% end %>
+ |
+
+ <% end %>
diff --git a/app/views/deliverables/show.html.erb b/app/views/deliverables/show.html.erb
index 03b82a306..5ac77b9ab 100755
--- a/app/views/deliverables/show.html.erb
+++ b/app/views/deliverables/show.html.erb
@@ -92,7 +92,7 @@
-<% if current_user.is_admin? || @course.faculty.include?(current_user) %>
+<% if current_user.is_admin? || @course.faculty_and_teaching_assistants.include?(current_user) %>
<%= render :partial => "edit_student_feedback", :locals => {:button_name => "Submit"} %>
<%# link_to "Alter feedback", deliverable_feedback_path(@deliverable) %>
<% elsif current_user.is_student? %>
diff --git a/db/migrate/20140503230056_create_teaching_assistant_assignments.rb b/db/migrate/20140503230056_create_teaching_assistant_assignments.rb
new file mode 100644
index 000000000..8c96788d2
--- /dev/null
+++ b/db/migrate/20140503230056_create_teaching_assistant_assignments.rb
@@ -0,0 +1,18 @@
+class CreateTeachingAssistantAssignments < ActiveRecord::Migration
+ def up
+ create_table "teaching_assistant_assignments", id: false, force: true do |t|
+ t.integer "course_id"
+ t.integer "user_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "teaching_assistant_assignments", ["course_id", "user_id"], name: "index_teaching_assistant_assignments_on_course_id_and_person_id", unique: true
+ end
+
+ def down
+ remove_index "teaching_assistant_assignments", name: "index_teaching_assistant_assignments_on_course_id_and_person_id"
+
+ drop_table "teaching_assistant_assignments"
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 6e020bf2c..929880a08 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20140124184429) do
+ActiveRecord::Schema.define(:version => 20140503230056) do
create_table "assignments", :force => true do |t|
t.string "name"
@@ -530,6 +530,15 @@
t.datetime "updated_at"
end
+ create_table "teaching_assistant_assignments", :id => false, :force => true do |t|
+ t.integer "course_id"
+ t.integer "user_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "teaching_assistant_assignments", ["course_id", "user_id"], :name => "index_teaching_assistant_assignments_on_course_id_and_person_id", :unique => true
+
create_table "team_assignments", :id => false, :force => true do |t|
t.integer "team_id"
t.integer "user_id"
diff --git a/spec/controllers/course_navigations_controller_spec.rb b/spec/controllers/course_navigations_controller_spec.rb
index 588edc0a6..c79f4ab94 100644
--- a/spec/controllers/course_navigations_controller_spec.rb
+++ b/spec/controllers/course_navigations_controller_spec.rb
@@ -21,6 +21,22 @@
end
+ context "any teaching assistang can" do
+ before do
+ login(FactoryGirl.create(:teaching_assistant_kyle))
+ end
+
+ describe "GET show" do
+ before do
+ get :show, :id => course.to_param
+ end
+
+ it "can't access page" do
+ response.should redirect_to(root_path)
+ end
+ end
+ end
+
context "any faculty can" do
before do
login(FactoryGirl.create(:faculty_frank))
diff --git a/spec/controllers/deliverables_controller_spec.rb b/spec/controllers/deliverables_controller_spec.rb
index c0b646c06..402657002 100644
--- a/spec/controllers/deliverables_controller_spec.rb
+++ b/spec/controllers/deliverables_controller_spec.rb
@@ -9,7 +9,8 @@
@faculty_fagan = FactoryGirl.create(:faculty_fagan)
@student_sam = FactoryGirl.create(:student_sam)
@student_sally = FactoryGirl.create(:student_sally)
-
+ @teaching_assistant_kyle = FactoryGirl.create(:teaching_assistant_kyle)
+ @teaching_assistant_plato = FactoryGirl.create(:teaching_assistant_plato)
end
@@ -269,6 +270,7 @@
@deliverable.stub(:team).and_return(@team)
@course.stub(:grading_rule).and_return(true)
+ @course.stub(:faculty_and_teaching_assistants).and_return([@faculty_frank, @faculty_fagan, @teaching_assistant_kyle, @teaching_assistant_plato])
@course.stub_chain(:grading_rule, :default_values?).and_return(true)
@course = Course.stub(:find).and_return(@course)
diff --git a/spec/controllers/grades_controller_spec.rb b/spec/controllers/grades_controller_spec.rb
index 0e696419b..3fa489340 100644
--- a/spec/controllers/grades_controller_spec.rb
+++ b/spec/controllers/grades_controller_spec.rb
@@ -9,6 +9,8 @@
@faculty_fagan = FactoryGirl.create(:faculty_fagan)
@student_sam = FactoryGirl.create(:student_sam)
@student_sally = FactoryGirl.create(:student_sally)
+ @teaching_assistant_kyle = FactoryGirl.create(:teaching_assistant_kyle)
+ @teaching_assistant_plato = FactoryGirl.create(:teaching_assistant_plato)
@assign_1 = mock_model(Assignment, :id => 1)
@course = mock_model(Course, :faculty => [@faculty_frank], :id => 1, :registered_students => [@student_sam, @student_sally], :assignments => [@assign_1, @assignment_2])
Grade.delete_all
@@ -32,6 +34,7 @@
@course.stub(:teams).and_return([Team.new, Team.new])
@grading_rule = FactoryGirl.build(:grading_rule)
@course.stub(:grading_rule).and_return(@grading_rule)
+ @course.stub(:faculty_and_teaching_assistants).and_return([@faculty_frank, @faculty_fagan, @teaching_assistant_kyle, @teaching_assistant_plato])
Grade.stub(:get_grades_for_student_per_course).with(@course, @student_sam).and_return({@assign_1.id => @grade_sam_assign1})
Grade.stub(:get_grades_for_student_per_course).with(@course, @student_sally).and_return({@assign_1.id => @grade_sally_assign1})
@expected_grades = {@student_sam => {@assign_1.id => @grade_sam_assign1},
diff --git a/spec/controllers/presentations_controller_spec.rb b/spec/controllers/presentations_controller_spec.rb
index edcf6bb93..920fd1439 100644
--- a/spec/controllers/presentations_controller_spec.rb
+++ b/spec/controllers/presentations_controller_spec.rb
@@ -442,6 +442,7 @@
@course = mock_model(Course, :faculty => [@faculty_frank], :course_id => 42)
@presentation = stub_model(Presentation, :course_id => @course.id)
Course.stub(:find).and_return(@course)
+ @course.stub(:faculty_and_teaching_assistants).and_return([@faculty_frank, @faculty_fagan, @teaching_assistant_kyle, @teaching_assistant_plato])
end
describe "GET index_for_course" do
diff --git a/spec/factories/factories.rb b/spec/factories/factories.rb
index a7e2f6df1..a172171b7 100644
--- a/spec/factories/factories.rb
+++ b/spec/factories/factories.rb
@@ -54,6 +54,11 @@
user_id 999
end
+ factory :teaching_assistant_assignment, class: TeachingAssistantAssignment do
+ course_id 1
+ user_id 51
+ end
+
factory :feedback_from_sam, class: PresentationFeedback do
association :evaluator, :factory => :student_sam
association :presentation, :factory => :presentation
diff --git a/spec/factories/people.rb b/spec/factories/people.rb
index 1e4b47b84..8dc96aa02 100644
--- a/spec/factories/people.rb
+++ b/spec/factories/people.rb
@@ -35,6 +35,28 @@
twiki_name "StudentSally"
end
+ factory :teaching_assistant_kyle, :parent => :person do
+ email "student.kyle@sv.cmu.edu"
+ webiso_account "kyle@andrew.cmu.edu"
+ is_student true
+ is_alumnus false
+ first_name "Teaching Assistant"
+ last_name "Kyle"
+ human_name "Teaching Assistant Kyle"
+ twiki_name "TeachingAssistantKyle"
+ end
+
+ factory :teaching_assistant_plato, :parent => :person do
+ email "student.plato@sv.cmu.edu"
+ webiso_account "plato@andrew.cmu.edu"
+ is_student true
+ is_alumnus false
+ first_name "Teaching Assistant"
+ last_name "Plato"
+ human_name "Teaching Assistant Plato"
+ twiki_name "TeachingAssistantPlato"
+ end
+
factory :faculty_frank, :parent => :person do
email "faculty.frank@sv.cmu.edu"
webiso_account "frank@andrew.cmu.edu"
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index bf9bedd2f..8bc07deeb 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -116,6 +116,32 @@
initialize_with { User.find_or_initialize_by_id(id) }
end
+ factory :teaching_assistant_kyle_user, :parent => :user do
+ id 51
+ email "student.kyle@sv.cmu.edu"
+ webiso_account "kyle@andrew.cmu.edu"
+ is_student true
+ is_alumnus false
+ first_name "Teaching Assistant"
+ last_name "Kyle"
+ human_name "Teaching Assistant Kyle"
+ twiki_name "TeachingAssistantKyle"
+ initialize_with { User.find_or_initialize_by_id(id) }
+ end
+
+ factory :teaching_assistant_plato_user, :parent => :user do
+ id 52
+ email "student.plato@sv.cmu.edu"
+ webiso_account "plato@andrew.cmu.edu"
+ is_student true
+ is_alumnus false
+ first_name "Teaching Assistant"
+ last_name "Plato"
+ human_name "Teaching Assistant Plato"
+ twiki_name "TeachingAssistantPlato"
+ initialize_with { User.find_or_initialize_by_id(id) }
+ end
+
factory :person_visible_to_setech, :parent => :people_search_default do
student_staff_group "All"
program_group "SE"
diff --git a/spec/models/course_model_spec.rb b/spec/models/course_model_spec.rb
index ae2b6337c..2437174cd 100644
--- a/spec/models/course_model_spec.rb
+++ b/spec/models/course_model_spec.rb
@@ -30,6 +30,42 @@
end
end
+ context "associations" do
+ before do
+ @course = FactoryGirl.build(:course)
+ @faculty_frank = FactoryGirl.create(:faculty_frank)
+ @course.faculty_assignments_override = [@faculty_frank.human_name]
+ @teaching_assistant_kyle = FactoryGirl.create(:teaching_assistant_kyle)
+ @teaching_assistant_plato = FactoryGirl.create(:teaching_assistant_plato)
+ @course.teaching_assistant_assignments_override = [@teaching_assistant_kyle.human_name, @teaching_assistant_plato.human_name]
+ @course.save
+ end
+
+ it 'properly reports faculty' do
+ @course.faculty.size.should == 1
+ @course.faculty.collect{ |x| x.id }.should == [@faculty_frank.id]
+ end
+
+ it 'properly reports teaching assistants' do
+ @course.teaching_assistants.size.should == 2
+ @course.teaching_assistants.collect{ |x| x.id }.should == [@teaching_assistant_kyle.id, @teaching_assistant_plato.id]
+ end
+
+ it 'properly reports faculty and teaching assistants' do
+ @course.faculty_and_teaching_assistants.size.should == 3
+ @course.faculty_and_teaching_assistants.collect{ |x| x.id }.should == [@faculty_frank.id, @teaching_assistant_kyle.id, @teaching_assistant_plato.id]
+ end
+
+ it "are copied when a new course is copied" do
+ new_course = @course.copy_as_new_course
+ new_course.save
+ new_course.faculty.should == @course.faculty
+ new_course.faculty.size.should == 1
+ new_course.teaching_assistants.should == @course.teaching_assistants
+ new_course.teaching_assistants.size.should == 2
+ new_course.faculty_and_teaching_assistants.should == @course.faculty_and_teaching_assistants
+ end
+ end
#it "display name should return the name" do
# @course = FactoryGirl.create(:mfse)
@@ -217,6 +253,8 @@
new_course = course.copy_as_new_course
new_course.save
new_course.faculty.should == course.faculty
+ new_course.teaching_assistants.should == course.teaching_assistants
+ new_course.faculty_and_teaching_assistants.should == course.faculty_and_teaching_assistants
end
end
@@ -272,6 +310,20 @@
end
end
+ context 'when the teaching assistants change' do
+ before do
+ @teaching_assistant_kyle = FactoryGirl.create(:teaching_assistant_kyle)
+ @course.teaching_assistant_assignments_override = [@teaching_assistant_kyle.human_name]
+ @course.save
+ end
+ it 'adds an asynchronous request' do
+ Delayed::Job.count.should > @count
+ end
+ it 'marks the state transition' do
+ @course.updating_email.should == true
+ end
+ end
+
context 'when the registered students change' do
#This needs to be tested in the HUB importer which manages this
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 9331c3d56..97fcb1bdc 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -12,6 +12,13 @@
end
+ it { should respond_to(:faculty_assignments) }
+ it { should respond_to(:teaching_these_courses) }
+ it { should respond_to(:teaching_assistant_assignments) }
+ it { should respond_to(:teacher_assisting_these_courses) }
+ it { should respond_to(:teaching_these_courses_during_current_semester) }
+ it { should respond_to(:teacher_assisting_these_courses_during_current_semester) }
+
describe "abilities" do
subject { ability }
let(:ability){ Ability.new(user) }
diff --git a/spec/requests/deliverables_spec.rb b/spec/requests/deliverables_spec.rb
index ac788bdce..dc08e43e7 100644
--- a/spec/requests/deliverables_spec.rb
+++ b/spec/requests/deliverables_spec.rb
@@ -121,11 +121,13 @@
context "As a professor" do
before do
@faculty = FactoryGirl.create(:faculty_frank_user)
+ @teaching_assistant = FactoryGirl.create(:teaching_assistant_kyle)
login_with_oauth @faculty
@team_deliverable.course.faculty = [@faculty]
@course = FactoryGirl.create(:fse)
@faculty_assignment = FactoryGirl.create(:faculty_assignment, :course_id => @course.id,
:user_id => @faculty.id)
+ @teaching_assistant_assignment = FactoryGirl.create(:teaching_assistant_assignment, :course_id => @course.id, :user_id => @teaching_assistant.id)
@team_deliverable.course = @course
@student_sam = FactoryGirl.create(:student_sam)
@@ -240,7 +242,9 @@
attach_file 'deliverable_attachment_attachment', Rails.root + 'spec/fixtures/sample_assignment.txt'
click_button "Create"
@professor = FactoryGirl.create(:faculty_frank_user)
+ @teaching_assitant = FactoryGirl.create(:teaching_assistant_kyle)
@assignment.course.faculty_assignments_override = [@professor.human_name]
+ @assignment.course.teaching_assistant_assignments_override = [@teaching_assistant.human_name]
@assignment.course.update_faculty
# Course.any_instance.stub(:faculty).and_return([@professor])
visit "/logout"
@@ -275,7 +279,9 @@
# attach_file 'deliverable_attachment_attachment', Rails.root + 'spec/fixtures/sample_assignment.txt'
# click_button "Create"
# @professor = FactoryGirl.create(:faculty_frank_user)
+ # @teaching_assistant = FactoryGirl.create(:teaching_assistant_kyle)
# @assignment.course.faculty_assignments_override = [@professor.human_name]
+ # @assignment.course.teaching_assitant_assignments_override = [@teaching_assistant.human_name]
# @assignment.course.update_faculty
# login_with_oauth @professor
# }
diff --git a/spec/services/people_in_a_collection_spec.rb b/spec/services/people_in_a_collection_spec.rb
index e9d7a2f49..62d174950 100644
--- a/spec/services/people_in_a_collection_spec.rb
+++ b/spec/services/people_in_a_collection_spec.rb
@@ -9,14 +9,20 @@
@faculty_frank = FactoryGirl.build(:faculty_frank, :id => rand(100))
@faculty_fagan = FactoryGirl.build(:faculty_fagan, :id => rand(100) + 100)
+ @teaching_assistant_kyle = FactoryGirl.build(:teaching_assistant_kyle, :id => rand(100))
+ @teaching_assistant_plato = FactoryGirl.build(:teaching_assistant_plato, :id => rand(100 + 100))
User.stub(:find_by_human_name).with(@faculty_frank.human_name).and_return(@faculty_frank)
User.stub(:find_by_human_name).with(@faculty_fagan.human_name).and_return(@faculty_fagan)
+ User.stub(:find_by_human_name).with(@teaching_assistant_kyle.human_name).and_return(@teaching_assistant_kyle)
+ User.stub(:find_by_human_name).with(@teaching_assistant_plato.human_name).and_return(@teaching_assistant_plato)
User.stub(:find_by_human_name).with("Someone not in the system").and_return(nil)
end
it "validates that the people are in the system" do
@course.faculty_assignments_override = [@faculty_frank.human_name, @faculty_fagan.human_name]
+ @course.teaching_assistant_assignments_override = [@teaching_assistant_kyle.human_name, @teaching_assistant_plato.human_name]
@course.validate_members :faculty_assignments_override
+ @course.validate_members :teaching_assistant_assignments_override
@course.valid?
@course.should be_valid
tmp = 1
@@ -29,6 +35,13 @@
@course.errors[:base].should include("Person Someone not in the system not found")
end
+ it "for teaching assistants not in the system, it sets an error" do
+ @course.teaching_assistant_assignments_override = [@teaching_assistant_kyle.human_name, "Someone not in the system", @teaching_assistant_plato.human_name]
+ @course.validate_members :teaching_assistant_assignments_override
+ @course.should_not be_valid
+ @course.errors[:base].should include("Person Someone not in the system not found")
+ end
+
it "assigns them to the faculty association" do
@course.faculty_assignments_override = [@faculty_frank.human_name, @faculty_fagan.human_name]
@course.update_faculty