CSC/ECE 517 Spring 2017 E1714

From Expertiza_Wiki
Revision as of 00:47, 23 March 2017 by Trichmo (talk | contribs) (Edit preconditions format)
Jump to navigation Jump to search

Motivation

Prior to our modifications, the Expertiza system offered no way for instructors to sign up or drop students from a topic. Instructors could impersonate a student, but this introduced unnecessary complexity to the process. By adding access to the signup functionality on the assignments page, instructors can now easily fix mistakes or free up topics as needed.

Modifications

sign_up_sheet/_topic_name.html.erb

The topic_name partial is the primary view for this feature. It renders the table cell where the topic, team, and students are listed. The following code was modified: <% for participant in @participants %>

 <% if topic.id == participant.topic_id %>
   <% chooser_present = true %>
     <% if(@assignment.max_team_size > 1)%>
       <br/>
       <b><%= participant.team_name_placeholder%><%= link_to image_tag('signup.png', :border => 0, :title => 'Waitlist Student', :align => 'middle'), signup_as_instructor_sign_up_sheet_index_path( assignment_id: params[:id], topic_id: topic.id) %></b>
       <br/>
       <%= participant.user_name_placeholder%><%= link_to image_tag('leave_topic.png', :border => 0, :title => 'Drop Student', :align => 'middle'), :controller => "sign_up_sheet", :action => "delete_signup_as_instructor", :id => participant.team_id, :topic_id => topic.id %>
     <% else %>
       <%= participant.user_name_placeholder%>
     <% end %>
     <% if participant.is_waitlisted == true %>
       <font color='red'>(waitlisted)</font>
     <% end %>
     <br/>
   <% end %>
 <% end %>
 <% if chooser_present == false %>
   No choosers.<%= link_to image_tag('signup.png', :border => 0, :title => 'Sign Up Student', :align => 'middle'), signup_as_instructor_sign_up_sheet_index_path( assignment_id: params[:id], topic_id: topic.id) %>
 <% end %>

The instructor will see a different set of links depending on whether or not a team has already been assigned to a topic. If no team is present, only a single link that adds a student and their team will be visible. If a team is already present, then an additional link that drops that existing team will be visible. In this case, the signup link will add students to the waitlist instead.

signup_sheet_controller.rb

The signup_sheet_controller is where most of the new functionality is introduced.

 def signup_as_instructor_action
   user = User.find_by(name: params[:username])
   unless user.nil? # validate invalid user
     unless SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])
       flash[:error] = "The student has already signed up for a topic!"
     end
     flash[:success] = "You have successfully signed up the student for the topic!"
   else
     flash[:error] = "That student does not exist!"
   end
   redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]
 end

 def delete_signup_as_instructor
   # find participant using assignment using team and topic ids
   team = Team.find(params[:id])
   assignment = Assignment.find(team.parent_id)
   teamUsr = TeamsUser.find_by(team_id: team.id)
   user = User.find(teamUsr.user_id)
   participant = AssignmentParticipant.find_by(user_id: user.id, parent_id: assignment.id)
   drop_topic_deadline = assignment.due_dates.find_by_deadline_type_id(6)
   if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?
     flash[:error] = "The student has already submitted their work, so you are not allowed to remove them."
   elsif !drop_topic_deadline.nil? and Time.now > drop_topic_deadline.due_at
     flash[:error] = "You cannot drop a student after the drop topic deadline!"
   else
     delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)
     flash[:success] = "You have successfully dropped the student from the topic!"
   end
   redirect_to controller: 'assignments', action: 'edit', id: assignment.id
 end

Testing

Preconditions

We create a user and instructor. The instructor is to add the user to one of two topics created for an assignment. The objects are refreshed each time.

Test Description Expected Result Tested File Method Tested
Add user to topic with no signed up team Correct user is added to topic Sign_up_sheet_controller.rb signup_as_instructor_action
Username does not exist in database flash[:error] = "The student does not exist!" Sign_up_sheet_controller.rb signup_as_instructor_action
Don’t allow to delete signup if submitted flash[:error] = "The student has already submitted their work, so you are not allowed to remove them." Sign_up_sheet_controller.rb delete_signup_as_instructor
Don’t allow delete signup with passed deadline flash[:error] = "You cannot drop the student after the drop topic deadline!" Sign_up_sheet_controller.rb delete_signup_as_instructor
Redirect Delete Signup Redirects back to topic list page Sign_up_sheet_controller.rb signup_as_instructor_action
Redirect Signup Redirects back to topic list page Sign_up_sheet_controller.rb delete_signup_as_instructor