CSC/ECE 517 Spring 2017 E1714

From Expertiza_Wiki
Revision as of 19:18, 23 March 2017 by Trichmo (talk | contribs) (→‎Peer Review Information: Added basic review steps)
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.

Peer Review Information

Please review the information below for further information on how to review the modifications made.

Login Information:

Username Password Role
instructor6 password instructor
student4340 password student
student4405 password student
student6376 password student

Review Steps:

  • Check with assignments a student is signed up for
    • Log in as a student
    • On the main page, there should be a list of assignments which the user can be removed from signup
      • Note removing the signup only works if the student hasn't turned in work or the drop deadline has not passed
  • Reaching assignment topics page
    • Login as an instructor
    • In the top red navigation bar, choose "Manage.."
    • Select "Assignments" above the search bar
    • Click the pencil button under actions column for any assignment
    • Select the "Topics" tab
  • Signing a student up
    • Navigate to the assignment topics page
    • Under the "Topic name(s)" column, click the checkmark for a given topic
    • At the redirected page, type in an existing student user
    • You should be redirected back to the "Edit Assignment" page, select the "Topics" tab to view your change
  • Remove a team's signup from a topic
    • Navigate to the assignment topics page
    • Under the "Topic name(s)" column, click the x surrounded by a red circle for a given topic
    • You should be redirected back to the "Edit Assignment" page, select the "Topics" tab to view your change
  • Check to ensure a student can see his addition or removal from a topic
    • Sign in as a student
    • Select the assignment of interest on the home page
    • The "your work" link should be grayed out with a message "(You have to choose a topic first) " if you've just removed the user's signup
    • The "your work" link should be active if you've signed the user up
      • Select the link "signup sheet"
      • The topic you've signed the user up for should be highlighted in yellow

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!"
     else
       flash[:success] = "You have successfully signed up the student for the topic!"
     end
   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