<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sjbarai</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sjbarai"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Sjbarai"/>
	<updated>2026-06-06T21:05:17Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17AA_Nomination_for_Badges&amp;diff=112831</id>
		<title>CSC/ECE 517 Fall 2017/E17AA Nomination for Badges</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17AA_Nomination_for_Badges&amp;diff=112831"/>
		<updated>2017-11-11T22:14:14Z</updated>

		<summary type="html">&lt;p&gt;Sjbarai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Problem Statement ==&lt;br /&gt;
&lt;br /&gt;
The purpose of the project is to implement a way to allow students to nominate badges to other students while reviewing their work. The professor should also be able to see the nominations to each student in a single page. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Pre-conditions==&lt;br /&gt;
&lt;br /&gt;
These are the pre-conditions that needs to hold true for each functionality to work&lt;br /&gt;
&lt;br /&gt;
:· The maximum number of students that can be assigned to the project cannot be more then 1. &lt;br /&gt;
:· For students to nominate badges, the professor must have provided a list of pre-decided badges possible for that project. &lt;br /&gt;
:· For students to be able to nominate badged without justification only if the project does not have a mandatory justification requirement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Implementation steps==&lt;br /&gt;
&lt;br /&gt;
:· Provide professors an option to add all possible badges to a project. &lt;br /&gt;
:· Allow students to nominate badges while peer reviewing.&lt;br /&gt;
:· Show a summary of all nominated badges to professor in a single page.&lt;/div&gt;</summary>
		<author><name>Sjbarai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17AA_Nomination_for_Badges&amp;diff=112830</id>
		<title>CSC/ECE 517 Fall 2017/E17AA Nomination for Badges</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17AA_Nomination_for_Badges&amp;diff=112830"/>
		<updated>2017-11-11T21:39:47Z</updated>

		<summary type="html">&lt;p&gt;Sjbarai: Created page with &amp;quot;== Problem Statement ==  The purpose of the project is to implement a way to allow students to nominate badges to other students while reviewing their work. The professor should ...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Problem Statement ==&lt;br /&gt;
&lt;br /&gt;
The purpose of the project is to implement a way to allow students to nominate badges to other students while reviewing their work. The professor should also be able to see the nominations to each student in a single page. &lt;br /&gt;
&lt;br /&gt;
==Pre-conditions==&lt;br /&gt;
&lt;br /&gt;
· The maximum number of students that can be assigned to the project cannot be more then 1.&lt;br /&gt;
· For students to nominate badges, the professor must have provided a list of pre-decided badges possible for that project. &lt;br /&gt;
· For students to be able to nominate badged without justification only if the project does not have a mandatory justification requirement.&lt;/div&gt;</summary>
		<author><name>Sjbarai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110788</id>
		<title>CSC/ECE 517 Fall 2017/E1771 Refactor team.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110788"/>
		<updated>2017-10-28T04:31:13Z</updated>

		<summary type="html">&lt;p&gt;Sjbarai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source webapp built on Ruby on Rails stack. It provides a platform to students with various features like peer-reviewing projects, submitting work, form teams, viewing grades etc. The project is being built and maintained by students and faculty at NCSU.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About team.rb ==&lt;br /&gt;
&lt;br /&gt;
team.rb is the default class to interact with the team table. team.rb has 2 subclasses assignment_team.rb and course_team.rb.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue ==&lt;br /&gt;
&lt;br /&gt;
team.rb is a fairly complex file. It contains a lot of methods that are long and hard to understand. &lt;br /&gt;
These methods need to be broken down into simpler and more specific methods that are easier to read/understand. Also, the few instances of code duplication that exist should be removed&lt;br /&gt;
&lt;br /&gt;
== Tasks accomplished ==&lt;br /&gt;
&lt;br /&gt;
    · Refactor self.randomize_all_by_parent method&lt;br /&gt;
        · Split into several simpler methods and assign reasonable names&lt;br /&gt;
        · Extract duplicated code into separate methods&lt;br /&gt;
    · Rename method and change all other places it is used&lt;br /&gt;
        · has_user →  user?&lt;br /&gt;
        · get_node_type → node_type&lt;br /&gt;
        · get_author_names → author_names&lt;br /&gt;
    · Pass &amp;amp;:destroy as an argument to each instead of a block&lt;br /&gt;
        · L22&lt;br /&gt;
    · Use find_by instead of dynamic method&lt;br /&gt;
        · L63, L153, L162&lt;br /&gt;
    · Use find_by instead of where.first&lt;br /&gt;
        · L166, L181 &lt;br /&gt;
    · Complete the pending tests in team_spec.rb, and write integration tests for newly-created methods. Refactor corresponding methods, and only then finish pending tests.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Elaborating the edits made: &lt;br /&gt;
&lt;br /&gt;
== Refactor self.randomize_all_by_parent method ==&lt;br /&gt;
&lt;br /&gt;
Previous code:&lt;br /&gt;
&lt;br /&gt;
  def self.randomize_all_by_parent(parent, team_type, min_team_size)&lt;br /&gt;
    participants = Participant.where(parent_id: parent.id, type: parent.class.to_s + &amp;quot;Participant&amp;quot;)&lt;br /&gt;
    participants = participants.sort { rand(3) - 1 }&lt;br /&gt;
    users = participants.map {|p| User.find(p.user_id) }.to_a&lt;br /&gt;
    # find teams still need team members and users who are not in any team&lt;br /&gt;
    teams = Team.where(parent_id: parent.id, type: parent.class.to_s + &amp;quot;Team&amp;quot;).to_a&lt;br /&gt;
    teams_num = teams.size&lt;br /&gt;
    i = 0&lt;br /&gt;
    teams_num.times do&lt;br /&gt;
      teams_users = TeamsUser.where(team_id: teams[i].id)&lt;br /&gt;
      teams_users.each do |teams_user|&lt;br /&gt;
        users.delete(User.find(teams_user.user_id))&lt;br /&gt;
      end&lt;br /&gt;
      if Team.size(teams.first.id) &amp;gt;= min_team_size&lt;br /&gt;
        teams.delete(teams.first)&lt;br /&gt;
      else&lt;br /&gt;
        i += 1&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # sort teams by decreasing team size&lt;br /&gt;
    teams.sort_by {|team| Team.size(team.id) }.reverse!&lt;br /&gt;
    # insert users who are not in any team to teams still need team members&lt;br /&gt;
    if !users.empty? and !teams.empty?&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        curr_team_size = Team.size(team.id)&lt;br /&gt;
        member_num_difference = min_team_size - curr_team_size&lt;br /&gt;
        for i in (1..member_num_difference).to_a&lt;br /&gt;
          team.add_member(users.first, parent.id)&lt;br /&gt;
          users.delete(users.first)&lt;br /&gt;
          break if users.empty?&lt;br /&gt;
        end&lt;br /&gt;
        break if users.empty?&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # If all the existing teams are fill to the min_team_size and we still have more users, create teams for them.&lt;br /&gt;
    unless users.empty?&lt;br /&gt;
      num_of_teams = users.length.fdiv(min_team_size).ceil&lt;br /&gt;
      nextTeamMemberIndex = 0&lt;br /&gt;
      for i in (1..num_of_teams).to_a&lt;br /&gt;
        team = Object.const_get(team_type + 'Team').create(name: &amp;quot;Team&amp;quot; + i.to_s, parent_id: parent.id)&lt;br /&gt;
        TeamNode.create(parent_id: parent.id, node_object_id: team.id)&lt;br /&gt;
        min_team_size.times do&lt;br /&gt;
          break if nextTeamMemberIndex &amp;gt;= users.length&lt;br /&gt;
          user = users[nextTeamMemberIndex]&lt;br /&gt;
          team.add_member(user, parent.id)&lt;br /&gt;
          nextTeamMemberIndex += 1&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This method has been edited and divided into following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== sort_teams_by_members_reverse() ==&lt;br /&gt;
&lt;br /&gt;
 def self.sort_teams_by_members_reverse(teams)&lt;br /&gt;
     teams.sort_by { |team| Team.size(team.id) }.reverse!&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== assign_single_users_to_teams ==&lt;br /&gt;
&lt;br /&gt;
 def self.assign_single_users_to_teams(min_team_size, parent, teams, users)&lt;br /&gt;
    teams.each do |team|&lt;br /&gt;
      curr_team_size = Team.size(team.id)&lt;br /&gt;
      member_num_difference = min_team_size - curr_team_size&lt;br /&gt;
      for i in (1..member_num_difference).to_a&lt;br /&gt;
        team.add_member(users.first, parent.id)&lt;br /&gt;
        users.delete(users.first)&lt;br /&gt;
        break if users.empty?&lt;br /&gt;
      end&lt;br /&gt;
      break if users.empty?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== create_team_from_single_users ==&lt;br /&gt;
&lt;br /&gt;
 def self.create_team_from_single_users(min_team_size, parent, team_type, users)&lt;br /&gt;
    num_of_teams = users.length.fdiv(min_team_size).ceil&lt;br /&gt;
    nextTeamMemberIndex = 0&lt;br /&gt;
    for i in (1..num_of_teams).to_a&lt;br /&gt;
      team = Object.const_get(team_type + 'Team').create(name: &amp;quot;Team&amp;quot; + i.to_s, parent_id: parent.id)&lt;br /&gt;
      TeamNode.create(parent_id: parent.id, node_object_id: team.id)&lt;br /&gt;
      min_team_size.times do&lt;br /&gt;
        break if nextTeamMemberIndex &amp;gt;= users.length&lt;br /&gt;
        user = users[nextTeamMemberIndex]&lt;br /&gt;
        team.add_member(user, parent.id)&lt;br /&gt;
        nextTeamMemberIndex += 1&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;/div&gt;</summary>
		<author><name>Sjbarai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110783</id>
		<title>CSC/ECE 517 Fall 2017/E1771 Refactor team.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110783"/>
		<updated>2017-10-28T04:19:09Z</updated>

		<summary type="html">&lt;p&gt;Sjbarai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source webapp built on Ruby on Rails stack. It provides a platform to students with various features like peer-reviewing projects, submitting work, form teams, viewing grades etc. The project is being built and maintained by students and faculty at NCSU.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About team.rb ==&lt;br /&gt;
&lt;br /&gt;
team.rb is the default class to interact with the team table. team.rb has 2 subclasses assignment_team.rb and course_team.rb.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue ==&lt;br /&gt;
&lt;br /&gt;
team.rb is a fairly complex file. It contains a lot of methods that are long and hard to understand. &lt;br /&gt;
These methods need to be broken down into simpler and more specific methods that are easier to read/understand. Also, the few instances of code duplication that exist should be removed&lt;br /&gt;
&lt;br /&gt;
== Tasks accomplished ==&lt;br /&gt;
&lt;br /&gt;
    · Refactor self.randomize_all_by_parent method&lt;br /&gt;
        · Split into several simpler methods and assign reasonable names&lt;br /&gt;
        · Extract duplicated code into separate methods&lt;br /&gt;
    · Rename method and change all other places it is used&lt;br /&gt;
        · has_user →  user?&lt;br /&gt;
        · get_node_type → node_type&lt;br /&gt;
        · get_author_names → author_names&lt;br /&gt;
    · Pass &amp;amp;:destroy as an argument to each instead of a block&lt;br /&gt;
        · L22&lt;br /&gt;
    · Use find_by instead of dynamic method&lt;br /&gt;
        · L63, L153, L162&lt;br /&gt;
    · Use find_by instead of where.first&lt;br /&gt;
        · L166, L181 &lt;br /&gt;
    · Complete the pending tests in team_spec.rb, and write integration tests for newly-created methods. Refactor corresponding methods, and only then finish pending tests.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Elaborating the edits made: &lt;br /&gt;
&lt;br /&gt;
== Refactor self.randomize_all_by_parent method ==&lt;br /&gt;
&lt;br /&gt;
Previous code:&lt;br /&gt;
&lt;br /&gt;
  def self.randomize_all_by_parent(parent, team_type, min_team_size)&lt;br /&gt;
    participants = Participant.where(parent_id: parent.id, type: parent.class.to_s + &amp;quot;Participant&amp;quot;)&lt;br /&gt;
    participants = participants.sort { rand(3) - 1 }&lt;br /&gt;
    users = participants.map {|p| User.find(p.user_id) }.to_a&lt;br /&gt;
    # find teams still need team members and users who are not in any team&lt;br /&gt;
    teams = Team.where(parent_id: parent.id, type: parent.class.to_s + &amp;quot;Team&amp;quot;).to_a&lt;br /&gt;
    teams_num = teams.size&lt;br /&gt;
    i = 0&lt;br /&gt;
    teams_num.times do&lt;br /&gt;
      teams_users = TeamsUser.where(team_id: teams[i].id)&lt;br /&gt;
      teams_users.each do |teams_user|&lt;br /&gt;
        users.delete(User.find(teams_user.user_id))&lt;br /&gt;
      end&lt;br /&gt;
      if Team.size(teams.first.id) &amp;gt;= min_team_size&lt;br /&gt;
        teams.delete(teams.first)&lt;br /&gt;
      else&lt;br /&gt;
        i += 1&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # sort teams by decreasing team size&lt;br /&gt;
    teams.sort_by {|team| Team.size(team.id) }.reverse!&lt;br /&gt;
    # insert users who are not in any team to teams still need team members&lt;br /&gt;
    if !users.empty? and !teams.empty?&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        curr_team_size = Team.size(team.id)&lt;br /&gt;
        member_num_difference = min_team_size - curr_team_size&lt;br /&gt;
        for i in (1..member_num_difference).to_a&lt;br /&gt;
          team.add_member(users.first, parent.id)&lt;br /&gt;
          users.delete(users.first)&lt;br /&gt;
          break if users.empty?&lt;br /&gt;
        end&lt;br /&gt;
        break if users.empty?&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # If all the existing teams are fill to the min_team_size and we still have more users, create teams for them.&lt;br /&gt;
    unless users.empty?&lt;br /&gt;
      num_of_teams = users.length.fdiv(min_team_size).ceil&lt;br /&gt;
      nextTeamMemberIndex = 0&lt;br /&gt;
      for i in (1..num_of_teams).to_a&lt;br /&gt;
        team = Object.const_get(team_type + 'Team').create(name: &amp;quot;Team&amp;quot; + i.to_s, parent_id: parent.id)&lt;br /&gt;
        TeamNode.create(parent_id: parent.id, node_object_id: team.id)&lt;br /&gt;
        min_team_size.times do&lt;br /&gt;
          break if nextTeamMemberIndex &amp;gt;= users.length&lt;br /&gt;
          user = users[nextTeamMemberIndex]&lt;br /&gt;
          team.add_member(user, parent.id)&lt;br /&gt;
          nextTeamMemberIndex += 1&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This method has been edited and divided into following methods:&lt;br /&gt;
&lt;br /&gt;
== sort_teams_by_members_reverse() ==&lt;br /&gt;
&lt;br /&gt;
 def self.sort_teams_by_members_reverse(teams)&lt;br /&gt;
     teams.sort_by { |team| Team.size(team.id) }.reverse!&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== assign_single_users_to_teams ==&lt;br /&gt;
&lt;br /&gt;
 def self.assign_single_users_to_teams(min_team_size, parent, teams, users)&lt;br /&gt;
    teams.each do |team|&lt;br /&gt;
      curr_team_size = Team.size(team.id)&lt;br /&gt;
      member_num_difference = min_team_size - curr_team_size&lt;br /&gt;
      for i in (1..member_num_difference).to_a&lt;br /&gt;
        team.add_member(users.first, parent.id)&lt;br /&gt;
        users.delete(users.first)&lt;br /&gt;
        break if users.empty?&lt;br /&gt;
      end&lt;br /&gt;
      break if users.empty?&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;/div&gt;</summary>
		<author><name>Sjbarai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110770</id>
		<title>CSC/ECE 517 Fall 2017/E1771 Refactor team.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110770"/>
		<updated>2017-10-28T04:04:16Z</updated>

		<summary type="html">&lt;p&gt;Sjbarai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source webapp built on Ruby on Rails stack. It provides a platform to students with various features like peer-reviewing projects, submitting work, form teams, viewing grades etc. The project is being built and maintained by students and faculty at NCSU.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About team.rb ==&lt;br /&gt;
&lt;br /&gt;
team.rb is the default class to interact with the team table. team.rb has 2 subclasses assignment_team.rb and course_team.rb.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue ==&lt;br /&gt;
&lt;br /&gt;
team.rb is a fairly complex file. It contains a lot of methods that are long and hard to understand. &lt;br /&gt;
These methods need to be broken down into simpler and more specific methods that are easier to read/understand. Also, the few instances of code duplication that exist should be removed&lt;br /&gt;
&lt;br /&gt;
== Tasks accomplished ==&lt;br /&gt;
&lt;br /&gt;
    · Refactor self.randomize_all_by_parent method&lt;br /&gt;
        · Split into several simpler methods and assign reasonable names&lt;br /&gt;
        · Extract duplicated code into separate methods&lt;br /&gt;
    · Rename method and change all other places it is used&lt;br /&gt;
        · has_user →  user?&lt;br /&gt;
        · get_node_type → node_type&lt;br /&gt;
        · get_author_names → author_names&lt;br /&gt;
    · Pass &amp;amp;:destroy as an argument to each instead of a block&lt;br /&gt;
        · L22&lt;br /&gt;
    · Use find_by instead of dynamic method&lt;br /&gt;
        · L63, L153, L162&lt;br /&gt;
    · Use find_by instead of where.first&lt;br /&gt;
        · L166, L181 &lt;br /&gt;
    · Complete the pending tests in team_spec.rb, and write integration tests for newly-created methods. Refactor corresponding methods, and only then finish pending tests.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Elaborating the edits made: &lt;br /&gt;
&lt;br /&gt;
== Refactor self.randomize_all_by_parent method ==&lt;br /&gt;
&lt;br /&gt;
Previous code:&lt;br /&gt;
&lt;br /&gt;
  def self.randomize_all_by_parent(parent, team_type, min_team_size)&lt;br /&gt;
    participants = Participant.where(parent_id: parent.id, type: parent.class.to_s + &amp;quot;Participant&amp;quot;)&lt;br /&gt;
    participants = participants.sort { rand(3) - 1 }&lt;br /&gt;
    users = participants.map {|p| User.find(p.user_id) }.to_a&lt;br /&gt;
    # find teams still need team members and users who are not in any team&lt;br /&gt;
    teams = Team.where(parent_id: parent.id, type: parent.class.to_s + &amp;quot;Team&amp;quot;).to_a&lt;br /&gt;
    teams_num = teams.size&lt;br /&gt;
    i = 0&lt;br /&gt;
    teams_num.times do&lt;br /&gt;
      teams_users = TeamsUser.where(team_id: teams[i].id)&lt;br /&gt;
      teams_users.each do |teams_user|&lt;br /&gt;
        users.delete(User.find(teams_user.user_id))&lt;br /&gt;
      end&lt;br /&gt;
      if Team.size(teams.first.id) &amp;gt;= min_team_size&lt;br /&gt;
        teams.delete(teams.first)&lt;br /&gt;
      else&lt;br /&gt;
        i += 1&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # sort teams by decreasing team size&lt;br /&gt;
    teams.sort_by {|team| Team.size(team.id) }.reverse!&lt;br /&gt;
    # insert users who are not in any team to teams still need team members&lt;br /&gt;
    if !users.empty? and !teams.empty?&lt;br /&gt;
      teams.each do |team|&lt;br /&gt;
        curr_team_size = Team.size(team.id)&lt;br /&gt;
        member_num_difference = min_team_size - curr_team_size&lt;br /&gt;
        for i in (1..member_num_difference).to_a&lt;br /&gt;
          team.add_member(users.first, parent.id)&lt;br /&gt;
          users.delete(users.first)&lt;br /&gt;
          break if users.empty?&lt;br /&gt;
        end&lt;br /&gt;
        break if users.empty?&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    # If all the existing teams are fill to the min_team_size and we still have more users, create teams for them.&lt;br /&gt;
    unless users.empty?&lt;br /&gt;
      num_of_teams = users.length.fdiv(min_team_size).ceil&lt;br /&gt;
      nextTeamMemberIndex = 0&lt;br /&gt;
      for i in (1..num_of_teams).to_a&lt;br /&gt;
        team = Object.const_get(team_type + 'Team').create(name: &amp;quot;Team&amp;quot; + i.to_s, parent_id: parent.id)&lt;br /&gt;
        TeamNode.create(parent_id: parent.id, node_object_id: team.id)&lt;br /&gt;
        min_team_size.times do&lt;br /&gt;
          break if nextTeamMemberIndex &amp;gt;= users.length&lt;br /&gt;
          user = users[nextTeamMemberIndex]&lt;br /&gt;
          team.add_member(user, parent.id)&lt;br /&gt;
          nextTeamMemberIndex += 1&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;/div&gt;</summary>
		<author><name>Sjbarai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110738</id>
		<title>CSC/ECE 517 Fall 2017/E1771 Refactor team.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110738"/>
		<updated>2017-10-28T03:46:13Z</updated>

		<summary type="html">&lt;p&gt;Sjbarai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source webapp built on Ruby on Rails stack. It provides a platform to students with various features like peer-reviewing projects, submitting work, form teams, viewing grades etc. The project is being built and maintained by students and faculty at NCSU.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== About team.rb ==&lt;br /&gt;
&lt;br /&gt;
team.rb is the default class to interact with the team table. team.rb has 2 subclasses assignment_team.rb and course_team.rb.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issue ==&lt;br /&gt;
&lt;br /&gt;
team.rb is a fairly complex file. It contains a lot of methods that are long and hard to understand. &lt;br /&gt;
These methods need to be broken down into simpler and more specific methods that are easier to read/understand. Also, the few instances of code duplication that exist should be removed&lt;br /&gt;
&lt;br /&gt;
== Tasks accomplished ==&lt;br /&gt;
&lt;br /&gt;
    · Refactor self.randomize_all_by_parent method&lt;br /&gt;
        · Split into several simpler methods and assign reasonable names&lt;br /&gt;
        · Extract duplicated code into separate methods&lt;br /&gt;
    · Rename method and change all other places it is used&lt;br /&gt;
        · has_user →  user?&lt;br /&gt;
        · get_node_type → node_type&lt;br /&gt;
        · get_author_names → author_names&lt;br /&gt;
    · Pass &amp;amp;:destroy as an argument to each instead of a block&lt;br /&gt;
        · L22&lt;br /&gt;
    · Use find_by instead of dynamic method&lt;br /&gt;
        · L63, L153, L162&lt;br /&gt;
    · Use find_by instead of where.first&lt;br /&gt;
        · L166, L181 &lt;br /&gt;
    · Complete the pending tests in team_spec.rb, and write integration tests for newly-created methods. Refactor corresponding methods, and only then finish pending tests.&lt;/div&gt;</summary>
		<author><name>Sjbarai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110679</id>
		<title>CSC/ECE 517 Fall 2017/E1771 Refactor team.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110679"/>
		<updated>2017-10-28T03:08:39Z</updated>

		<summary type="html">&lt;p&gt;Sjbarai: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Introduction&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source webapp built on Ruby on Rails stack. It provides a platform to students with various features like peer-reviewing projects, submitting work, form teams, viewing grades etc. The project is being built and maintained by students and faculty at NCSU.&lt;/div&gt;</summary>
		<author><name>Sjbarai</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110674</id>
		<title>CSC/ECE 517 Fall 2017/E1771 Refactor team.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1771_Refactor_team.rb&amp;diff=110674"/>
		<updated>2017-10-28T03:06:48Z</updated>

		<summary type="html">&lt;p&gt;Sjbarai: Created page with &amp;quot;dummy dummy dummy&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;dummy&lt;br /&gt;
dummy&lt;br /&gt;
dummy&lt;/div&gt;</summary>
		<author><name>Sjbarai</name></author>
	</entry>
</feed>