CSC/ECE 517 Fall 2015/oss E1554 AAR: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
(Created page with "'''E1554 Refactoring TeamsController.rb''' This is description of the CSC/ECE 517 Fall2015 OSS project(E1554),we refactored teams_controller.rb,students_team_controller.rb,sign_u...")
 
No edit summary
 
(34 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''E1554 Refactoring TeamsController.rb'''
'''E1554 Refactoring TeamsController.rb'''
This is description of the CSC/ECE 517 Fall2015 OSS project(E1554),we refactored teams_controller.rb,students_team_controller.rb,sign_up_topic.rb we extracted the duplicate code into a single function call,and we made sure when team is deleted its associated records are deleted first then the team gets deleted.
This is description of the CSC/ECE 517 Fall2015 OSS project(E1554),we refactored teams_controller.rb,students_team_controller.rb,sign_up_topic.rb we extracted the duplicate code into a single function call,and we made sure when team is deleted its associated records are deleted first then the team gets deleted.We have tested using [http://rspec.info/ Rspec]




== Expertiza ==
== Expertiza ==


[[Expertiza]][[http://wikis.lib.ncsu.edu/index.php/Expertiza]] is a project built with Ruby on Rails.It is mainly used by an instructor to provide a peer reviewing systems among the students it also supports team projects submissions wikis etc.  
Expertiza <ref>[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza].''expertiza project''</ref> is a project built with [https://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails]<ref>[http://rubyonrails.org/ RubyonRails]</ref>.It is mainly used by an instructor to provide a peer reviewing systems among the students it also supports team projects submissions wikis etc.
 


== What it Does ==
== What it Does ==
This class handle the basic creation and modification of student teams.  There are also some complicated actions. E.g., if a team get destroyed (this may be caused by instructor force this team to be destroyed, the students all leave the team), the topic held by this team should be transferred to next team which is on the waiting list, if there is any.
This class handle the basic creation and modification of student teams.  There are also some complicated actions. E.g., if a team get destroyed (this may be caused by instructor force this team to be destroyed, the students all leave the team), the topic held by this team should be transferred to next team which is on the waiting list, if there is any.
These are the scenarios where topic transferring may happen:  
These are the scenarios where topic transferring may happen:  
1) when instructor destroys a team  
* when instructor destroys a team  
2) when the last person leave this team  
* when the last person leave this team  
3) when this team wants to switch topic  
* when this team wants to switch topic  
4) when instructor wants to increase the available slots for a topic.
* when instructor wants to increase the available slots for a topic.




Line 27: Line 26:


== What Needs to be Done ==
== What Needs to be Done ==
Make topic_transfering a function call, and make sure all those 4 scenario works.
*Make topic_transfering a function call, and make sure all those 4 scenario works.
Fix issue 540 which is scenario 4 above.
*Write tests for all those 4 scenarios.
Write tests for all those 4 scenarios.
*Record a video for those 4 scenarios, submit it to YouTube and submit the YouTube link to Expertiza.
Record a video for those 4 scenarios, submit it to YouTube and submit the YouTube link to Expertiza.
*Delete method in teams_controller.rb is complicated, “@team.destroy” should be called latest after all the records related to this team can be deleted.
Delete method in teams_controller.rb is complicated, here are some ideas to refactor: 1) “@team.destroy” should be called latest after all the records related to this team can be deleted; 2) destroying teams_users records can be extracted into a method in teams_users.rb; 3) line 95 -102 (if next_wait_listed_team...end) is duplicated at 3 places and should be extracted into a single method.
*write tests for delete method.
You should also write tests for delete method.
 
 
== Implementing the repeated code as function call ==
 
 
Before: Code repeated in teams_controller.rb, student_teams_controller.rb, SignUpTopic.rb
 
  if next_wait_listed_team
    team_id = next_wait_listed_team.team_id
    team = Team.find(team_id)
    assignment_id = team.parent_id
    next_wait_listed_team.is_waitlisted = false
    next_wait_listed_team.save
    Waitlist.cancel_all_waitlists(team_id, assignment_id)
  end
 
 
After: The repeated code implemented as a function in SignUpTopic.rb
def self.assign_to_first_waiting_team(next_wait_listed_team)
    team_id = next_wait_listed_team.team_id
    team = Team.find(team_id)
    assignment_id = team.parent_id
    next_wait_listed_team.is_waitlisted = false
    next_wait_listed_team.save
    Waitlist.cancel_all_waitlists(team_id, assignment_id)
end  
 
 
==Refactoring the Order of deleting a team and its attributes==
Problem: The team is deleted even before its attributes are destroyed in teams_controller.rb
Before:
  @team.destroy if @team
  @signUps = SignedUpTeam.where(team_id: params[:id])
  @teams_users = TeamsUser.where(team_id: params[:id])
  @teams_users.destroy_all if @teams_users
  if @signUps.size == 1 and @signUps.first.is_waitlisted == false #this team hold a topic
 
After:
  @team = Team.find(params[:id])
  course = Object.const_get(session[:team_type]).find(@team.parent_id)
  @signUps = SignedUpTeam.where(team_id: @team.id)
  @teams_users = TeamsUser.where(team_id: @team.id)
  if @signUps.size == 1 and @signUps.first.is_waitlisted == false
 
 
== Rspec Testing ==
 
 
Rspec tests can be performed by using the following commands from expertiza directory in the terminal:
 
 
 
bundle exec rake db:reset RAILS_ENV=test
rspec spec/controllers/teams_controller_spec.rb
 
 
== Manual Testing ==
*Login as instructor.
*Create a course.
*Create a assignment using the above course.
*Create topics (two topics are sufficient, though one will be used).
*Create Users (at least 4 for better understanding : User21, User22. User23, User24).
*Add users as participants to the assignment.
*Create teams (TeamX -> User21 , User22) and (TeamY -> User23 , User24).
*Impersonate as user and choose the topic first, invite other user. Impersonate as other user, accept the invite.
*Revert to instructor role after creating teams.
 
Make sure you have the same setup as above before every scenario.
 
Scenario 1:
*Go to Manage Content > the assignment you created > select 'Create Team' icon > delete the first team.
*There will be only one team now.
*Go to Manage Content > the assignment you created > select 'Edit' icon > Topics Tab
*The second team will have the topic on which it was wait listed.
*Check 'Number of slots' , 'Available Slots','Number on Wait list'.
 
Scenario 2:
*Impersonate as user of the team which has the topic.
*Leave from the team.
*Impersonate as second user of the team which has the topic.
*Leave from the team.
*Revert to instructor role after creating teams.
*Go to Manage Content > the assignment you created > select 'Edit' icon > Topics Tab
*The second team will have the topic on which it was wait listed.
*Check 'Number of slots' , 'Available Slots','Number on Wait list'.
 
Scenario 4:
*Go to Manage Content > the assignment you created > select 'Edit' icon > Topics Tab
*Select 'Edit' icon for that topic.
*Increase the number of slots to 2 or more.
*The second team will have the topic on which it was wait listed.
[https://www.youtube.com/watch?v=rnRDC8pge7o&feature=youtu.be This] Youtube video will guide you test functionality manually.
 
== References ==
<references />

Latest revision as of 06:21, 2 November 2015

E1554 Refactoring TeamsController.rb This is description of the CSC/ECE 517 Fall2015 OSS project(E1554),we refactored teams_controller.rb,students_team_controller.rb,sign_up_topic.rb we extracted the duplicate code into a single function call,and we made sure when team is deleted its associated records are deleted first then the team gets deleted.We have tested using Rspec


Expertiza

Expertiza <ref>Expertiza.expertiza project</ref> is a project built with Ruby on Rails<ref>RubyonRails</ref>.It is mainly used by an instructor to provide a peer reviewing systems among the students it also supports team projects submissions wikis etc.

What it Does

This class handle the basic creation and modification of student teams. There are also some complicated actions. E.g., if a team get destroyed (this may be caused by instructor force this team to be destroyed, the students all leave the team), the topic held by this team should be transferred to next team which is on the waiting list, if there is any. These are the scenarios where topic transferring may happen:

  • when instructor destroys a team
  • when the last person leave this team
  • when this team wants to switch topic
  • when instructor wants to increase the available slots for a topic.


Problem Statement

The same code for handling topic transferring used 3 times at the following places:

[scenario 1] teams_controller line 95 (if next_wait_listed_team), 
[scenario 2] student_teams_controller line 139 (if first_waitlisted_team) and 
[scenario 4] sign_up_topic line 117 (if next_wait_listed_team). 
Scenario 3’s code is not copied, and one can find the code at line 92 in sign_up_topic.rb.


What Needs to be Done

  • Make topic_transfering a function call, and make sure all those 4 scenario works.
  • Write tests for all those 4 scenarios.
  • Record a video for those 4 scenarios, submit it to YouTube and submit the YouTube link to Expertiza.
  • Delete method in teams_controller.rb is complicated, “@team.destroy” should be called latest after all the records related to this team can be deleted.
  • write tests for delete method.


Implementing the repeated code as function call

Before: Code repeated in teams_controller.rb, student_teams_controller.rb, SignUpTopic.rb

  if next_wait_listed_team
   team_id = next_wait_listed_team.team_id
   team = Team.find(team_id)
   assignment_id = team.parent_id
   next_wait_listed_team.is_waitlisted = false
   next_wait_listed_team.save
   Waitlist.cancel_all_waitlists(team_id, assignment_id)
 end


After: The repeated code implemented as a function in SignUpTopic.rb


def self.assign_to_first_waiting_team(next_wait_listed_team)
   team_id = next_wait_listed_team.team_id
   team = Team.find(team_id)
   assignment_id = team.parent_id
   next_wait_listed_team.is_waitlisted = false
   next_wait_listed_team.save
   Waitlist.cancel_all_waitlists(team_id, assignment_id)
end 


Refactoring the Order of deleting a team and its attributes

Problem: The team is deleted even before its attributes are destroyed in teams_controller.rb Before:

 @team.destroy if @team
 @signUps = SignedUpTeam.where(team_id: params[:id])
 @teams_users = TeamsUser.where(team_id: params[:id])
 @teams_users.destroy_all if @teams_users
 if @signUps.size == 1 and @signUps.first.is_waitlisted == false #this team hold a topic

After:


 @team = Team.find(params[:id])
 course = Object.const_get(session[:team_type]).find(@team.parent_id)
 @signUps = SignedUpTeam.where(team_id: @team.id)
 @teams_users = TeamsUser.where(team_id: @team.id)
 if @signUps.size == 1 and @signUps.first.is_waitlisted == false


Rspec Testing

Rspec tests can be performed by using the following commands from expertiza directory in the terminal:


bundle exec rake db:reset RAILS_ENV=test 
rspec spec/controllers/teams_controller_spec.rb 


Manual Testing

  • Login as instructor.
  • Create a course.
  • Create a assignment using the above course.
  • Create topics (two topics are sufficient, though one will be used).
  • Create Users (at least 4 for better understanding : User21, User22. User23, User24).
  • Add users as participants to the assignment.
  • Create teams (TeamX -> User21 , User22) and (TeamY -> User23 , User24).
  • Impersonate as user and choose the topic first, invite other user. Impersonate as other user, accept the invite.
  • Revert to instructor role after creating teams.

Make sure you have the same setup as above before every scenario.

Scenario 1:

  • Go to Manage Content > the assignment you created > select 'Create Team' icon > delete the first team.
  • There will be only one team now.
  • Go to Manage Content > the assignment you created > select 'Edit' icon > Topics Tab
  • The second team will have the topic on which it was wait listed.
  • Check 'Number of slots' , 'Available Slots','Number on Wait list'.

Scenario 2:

  • Impersonate as user of the team which has the topic.
  • Leave from the team.
  • Impersonate as second user of the team which has the topic.
  • Leave from the team.
  • Revert to instructor role after creating teams.
  • Go to Manage Content > the assignment you created > select 'Edit' icon > Topics Tab
  • The second team will have the topic on which it was wait listed.
  • Check 'Number of slots' , 'Available Slots','Number on Wait list'.

Scenario 4:

  • Go to Manage Content > the assignment you created > select 'Edit' icon > Topics Tab
  • Select 'Edit' icon for that topic.
  • Increase the number of slots to 2 or more.
  • The second team will have the topic on which it was wait listed.

This Youtube video will guide you test functionality manually.

References

<references />