<?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=Vspande</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=Vspande"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Vspande"/>
	<updated>2026-05-18T01:00:35Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149739</id>
		<title>CSC/ECE 517/Spring 2023/E2332 Reimplement Courses (Refactor course.rb)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149739"/>
		<updated>2023-04-14T14:35:58Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails, which functions as a learning management software system. It has many different functions and abilities, including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and a list of operations that can be performed on the course model. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model and &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt;, which are the classes primarily addressed in this project, are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model stores information about the instructor and institution it belongs to, and it is associated with other models such as User, Assignment, etc. The course model is responsible for completing a variety of tasks, including returning the submission directory for the course, viewing students enrolled in the course, and adding a student to the course, etc.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt; is responsible for managing courses. It performs CRUD operations on the Course model. It is responsible for creating, editing, deleting courses, and adding/removing teaching assistants to the course. The controller also returns a list of Teaching assistants associated with the course.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The problem statement requires us to re-implement the Course model and CoursesController in a Rails application, with the goal of managing courses by allowing admins to create, edit, update, and delete courses, as well as create copies of existing courses. The re-implementation should follow RESTful conventions, including appropriate HTTP response codes and status codes for each endpoint. We are required to write RSpec tests for the Course model and the CoursesController, covering all endpoints and including appropriate HTTP response codes for every method. Tests for the controller will be made compatible with RSwag to generate API documentation and test REST APIs from the Swagger UI.&lt;br /&gt;
&lt;br /&gt;
==Previous Work==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Previous !! Proposed changes || Rationale&lt;br /&gt;
|-&lt;br /&gt;
| 1 || user_on_team method in course.rb model &lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
  def user_on_team?(user)&lt;br /&gt;
    teams = get_teams&lt;br /&gt;
    users = []&lt;br /&gt;
    teams.each do |team|&lt;br /&gt;
      users &amp;lt;&amp;lt; team.users&lt;br /&gt;
    end&lt;br /&gt;
    users.flatten.include? user&lt;br /&gt;
  end&lt;br /&gt;
'''&lt;br /&gt;
|| user_on_team method in team.rb || The functionality to check whether a user is a member of any team is associated with team model, follows Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
| 2 || copy method present in controller &lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
 # Create a copy of a course with a new submission directory&lt;br /&gt;
  def copy&lt;br /&gt;
    orig_course = Course.find(params[:id])&lt;br /&gt;
    new_course = orig_course.dup&lt;br /&gt;
    new_course.instructor_id = session[:user].id&lt;br /&gt;
    new_course.name = 'Copy of ' + orig_course.name&lt;br /&gt;
    new_course.directory_path = new_course.directory_path + '_copy'&lt;br /&gt;
    begin&lt;br /&gt;
      new_course.save!&lt;br /&gt;
      parent_id = CourseNode.get_parent_id&lt;br /&gt;
      if parent_id&lt;br /&gt;
        CourseNode.create(node_object_id: new_course.id, parent_id: parent_id)&lt;br /&gt;
      else&lt;br /&gt;
        CourseNode.create(node_object_id: new_course.id)&lt;br /&gt;
      end&lt;br /&gt;
      undo_link(&amp;quot;The course \&amp;quot;#{orig_course.name}\&amp;quot; has been successfully copied.&lt;br /&gt;
        Warning: The submission directory path for this copy is the original course's directory path appended with the word \&amp;quot;_copy\&amp;quot;.&lt;br /&gt;
        If you do not want this to happen, change the submission directory in the new copy of the course.&amp;quot;)&lt;br /&gt;
      redirect_to controller: 'courses', action: 'edit', id: new_course.id&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = 'The course was not able to be copied: ' + $ERROR_INFO&lt;br /&gt;
      redirect_to controller: 'tree_display', action: 'list'&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
'''&lt;br /&gt;
|| copy method should be added in the model as well ||  The controller should not have the logic of copying the course attributes, instead, the controller should call the copy method defined in the model to create a copy of a course.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || action_allowed method in controller &lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
 def action_allowed?&lt;br /&gt;
    current_user_has_instructor_privileges?&lt;br /&gt;
 end&lt;br /&gt;
'''&lt;br /&gt;
|| action_allowed method should be in a model which deals with authorization ||  The course model class does not have the responsibility to check whether the user has instructor privileges.&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Based on the current functionality of the Course model and controller we have defined the following RESTful endpoints with their Request type which would be implemented in the controller. The Strategy Pattern will be followed in the context of a controller, this pattern can be used to encapsulate the actions that the controller can perform and make them easily extensible and usable.&lt;br /&gt;
====Controller====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Request Type !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || action_allowed || HELPER FUNCTION || Determines whether the current user has permission to perform certain actions based on their role&lt;br /&gt;
|-&lt;br /&gt;
| 2 || auto_complete_for_user_name || GET || Provides an autocomplete feature for the form input when adding a TA&lt;br /&gt;
|-&lt;br /&gt;
| 3 || new || GET || Displays the form for creating a new course&lt;br /&gt;
|-&lt;br /&gt;
| 4 || edit|| GET || Method to get the course to edit&lt;br /&gt;
|-&lt;br /&gt;
| 5 || update || PUT || Method to update an existing course based on the form input and save the changes to database&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy || GET || Creates a new copy of an existing course with a new submission directory and saves it to the database&lt;br /&gt;
|-&lt;br /&gt;
| 7 || create || POST || Creates a new course based on the form input and saves it to database&lt;br /&gt;
|-&lt;br /&gt;
| 8 || delete || DELETE || Method to delete an existing course&lt;br /&gt;
|-&lt;br /&gt;
| 9 || view_teaching_assistant || GET || Displays all the teaching assistants for a course&lt;br /&gt;
|-&lt;br /&gt;
| 10 || add_ta || POST || Method to add teaching assistant to a course&lt;br /&gt;
|-&lt;br /&gt;
| 11 || remove_ta || POST || Method to remove teaching assistant from a course&lt;br /&gt;
|-&lt;br /&gt;
| 12 || set_course_fields || POST || Called in Update and Create methods to set the fields of course&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Model====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || get_teams || Returns any predefined teams associated with a particular course object&lt;br /&gt;
|-&lt;br /&gt;
| 2 || get_participants || Returns multiple records of course participants from database given parent_id and user_id&lt;br /&gt;
|-&lt;br /&gt;
| 3 || get_participant || Returns a single record course participant from Course Participant given parent_id&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add _participant || Add a new Course Participant to the course given user_name&lt;br /&gt;
|-&lt;br /&gt;
| 5 || copy_participants || Copies all the participants from a given assignment to the current course&lt;br /&gt;
|-&lt;br /&gt;
| 6 || user_on_team || Checks whether a given user is a member of any team associated with the course&lt;br /&gt;
|-&lt;br /&gt;
| 7 || path || Returns the course's submission directory&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
[[Image: UML.png]]&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
The Course model and controller will be tested using Rspec. FactoryBot will be utilized to create test fixtures and to build the required models. As the methods in the controller are defined as RESTful endpoints. The test take into consideration that the methods return the correct status codes for the output. Based on the current functionality of Course model and controller we have defined the following test which would implemented to test the reimplemented code of course model and controller. &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
'''Course Controller'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the action_allowed disallows all actions when current user is student.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the action_allowed allows all course actions when current user is instructor.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if create method returns a 201 Created status code if the resource is successfully created.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if create method returns a 422 Unprocessable Entity status code if the resource cannot be created due to validation errors.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Tests if the delete method returns a 204 No Content status code if the resource is successfully deleted.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Tests if the delete method returns a 404 Not Found status code if the resource cannot be found.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tests if the new method sets the private instance variable.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Tests if the update method returns a 200 OK status code if the resource is successfully updated.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Tests if the update method returns a 422 Unprocessable Entity status code if the resource cannot be updated due to validation errors.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Tests if the topic_name method returns the participant topic name when not nil.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Tests if the auto_complete_for_user_name method returns a list of users.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Tests if the copy method redirects to new course when new course id fetched successfully.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the view_teaching_assistants method returns list of TAs for the course.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the add_ta method returns a 200 OK status code if a TA added successfully to the course.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the add_ta method returns a 422 Unprocessable Entity status code if a TA cannot be added to the course.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the remove_ta method returns a 204 No Content status code if the ta is successfully removed from the course.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Tests if the remove_ta method returns a 404 Not Found status code if the ta cannot be found.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Tests if the set_course_fields method sets the course fields.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Course Model'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the model validates presence of name&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the model validates presence of directory_path&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if path method raises an error when there is no associated instructor.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if path method returns a directory when there is an associated instructor.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/ameyagv/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149705</id>
		<title>CSC/ECE 517/Spring 2023/E2332 Reimplement Courses (Refactor course.rb)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149705"/>
		<updated>2023-04-13T02:28:27Z</updated>

		<summary type="html">&lt;p&gt;Vspande: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails, which functions as a learning management software system. It has many different functions and abilities, including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and a list of operations that can be performed on the course model. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model and &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt;, which are the classes primarily addressed in this project, are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model stores information about the instructor and institution it belongs to, and it is associated with other models such as User, Assignment, etc. The course model is responsible for completing a variety of tasks, including returning the submission directory for the course, viewing students enrolled in the course, and adding a student to the course, etc.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt; is responsible for managing courses. It performs CRUD operations on the Course model. It is responsible for creating, editing, deleting courses, and adding/removing teaching assistants to the course. The controller also returns a list of Teaching assistants associated with the course.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The problem statement requires us to re-implement the Course model and CoursesController in a Rails application, with the goal of managing courses by allowing admins to create, edit, update, and delete courses, as well as create copies of existing courses. The re-implementation should follow RESTful conventions, including appropriate HTTP response codes and status codes for each endpoint. We are required to write RSpec tests for the Course model and the CoursesController, covering all endpoints and including appropriate HTTP response codes for every method. Tests for the controller will be made compatible with RSwag to generate API documentation and test REST APIs from the Swagger UI.&lt;br /&gt;
&lt;br /&gt;
==Previous Work==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Previous !! Proposed || Rationale&lt;br /&gt;
|-&lt;br /&gt;
| 1 || user_on_team method in course.rb model || user_on_team method in team.rb || The functionality to check whether a user is a member of any team is associated with team model, follows Single Responsibility Principle &lt;br /&gt;
|-&lt;br /&gt;
| 2 || copy method present in controller || copy method should be added in model as well ||  &lt;br /&gt;
|-&lt;br /&gt;
| 3 || action_allowed method in controller || action_allowed method should be in user.rb ||  It should belong to Authorization part.&lt;br /&gt;
|-&lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Based on the current functionality of Course model and controller we have defined the following RESTful endpoints with their Request type which would be implemented in the controller.&lt;br /&gt;
====Controller====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Request Type !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || action_allowed || HELPER FUNCTION || Determines whether the current user has permission to perform certain actions based on their role&lt;br /&gt;
|-&lt;br /&gt;
| 2 || auto_complete_for_user_name || GET || Provides an autocomplete feature for the form input when adding a TA&lt;br /&gt;
|-&lt;br /&gt;
| 3 || new || GET || Displays the form for creating a new course&lt;br /&gt;
|-&lt;br /&gt;
| 4 || edit|| GET || Method to get the course to edit&lt;br /&gt;
|-&lt;br /&gt;
| 5 || update || PUT || Method to update an existing course based on the form input and save the changes to database&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy || GET || Creates a new copy of an existing course with a new submission directory and saves it to the database&lt;br /&gt;
|-&lt;br /&gt;
| 7 || create || POST || Creates a new course based on the form input and saves it to database&lt;br /&gt;
|-&lt;br /&gt;
| 8 || delete || DELETE || Method to delete an existing course&lt;br /&gt;
|-&lt;br /&gt;
| 9 || view_teaching_assistant || GET || Displays all the teaching assistants for a course&lt;br /&gt;
|-&lt;br /&gt;
| 10 || add_ta || POST || Method to add teaching assistant to a course&lt;br /&gt;
|-&lt;br /&gt;
| 11 || remove_ta || POST || Method to remove teaching assistant from a course&lt;br /&gt;
|-&lt;br /&gt;
| 12 || set_course_fields || POST || Called in Update and Create methods to set the fields of course&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Model====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || get_teams || Returns any predefined teams associated with a particular course object&lt;br /&gt;
|-&lt;br /&gt;
| 2 || get_participants || Returns multiple records of course participants from database given parent_id and user_id&lt;br /&gt;
|-&lt;br /&gt;
| 3 || get_participant || Returns a single record course participant from Course Participant given parent_id&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add _participant || Add a new Course Participant to the course given user_name&lt;br /&gt;
|-&lt;br /&gt;
| 5 || copy_participants || Copies all the participants from a given assignment to the current course&lt;br /&gt;
|-&lt;br /&gt;
| 6 || user_on_team || Checks whether a given user is a member of any team associated with the course&lt;br /&gt;
|-&lt;br /&gt;
| 7 || path || Returns the course's submission directory&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
[[Image: UML.png]]&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
The Course model and controller will be tested using Rspec. FactoryBot will be utilized to create test fixtures and to build the required models. As the methods in the controller are defined as RESTful endpoints. The test take into consideration that the methods return the correct status codes for the output. Based on the current functionality of Course model and controller we have defined the following test which would implemented to test the reimplemented code of course model and controller. &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
'''Course Controller'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the action_allowed disallows all actions when current user is student.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the action_allowed allows all course actions when current user is instructor.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if create method returns a 201 Created status code if the resource is successfully created.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if create method returns a 422 Unprocessable Entity status code if the resource cannot be created due to validation errors.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Tests if the delete method returns a 204 No Content status code if the resource is successfully deleted.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Tests if the delete method returns a 404 Not Found status code if the resource cannot be found.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tests if the new method sets the private instance variable.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Tests if the update method returns a 200 OK status code if the resource is successfully updated.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Tests if the update method returns a 422 Unprocessable Entity status code if the resource cannot be updated due to validation errors.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Tests if the topic_name method returns the participant topic name when not nil.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Tests if the auto_complete_for_user_name method returns a list of users.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Tests if the copy method redirects to new course when new course id fetched successfully.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the view_teaching_assistants method returns list of TAs for the course.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the add_ta method returns a 200 OK status code if a TA added successfully to the course.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the add_ta method returns a 422 Unprocessable Entity status code if a TA cannot be added to the course.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the remove_ta method returns a 204 No Content status code if the ta is successfully removed from the course.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Tests if the remove_ta method returns a 404 Not Found status code if the ta cannot be found.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Tests if the set_course_fields method sets the course fields.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Course Model'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the model validates presence of name&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the model validates presence of directory_path&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if path method raises an error when there is no associated instructor.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if path method returns a directory when there is an associated instructor.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/ameyagv/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149503</id>
		<title>CSC/ECE 517/Spring 2023/E2332 Reimplement Courses (Refactor course.rb)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149503"/>
		<updated>2023-04-12T21:28:03Z</updated>

		<summary type="html">&lt;p&gt;Vspande: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails, which functions as a learning management software system. It has many different functions and abilities, including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and a list of operations that can be performed on the course model. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model and &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt;, which are the classes primarily addressed in this project, are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model stores information about the instructor and institution it belongs to, and it is associated with other models such as User, Assignment, etc. The course model is responsible for completing a variety of tasks, including returning the submission directory for the course, viewing students enrolled in the course, and adding a student to the course, etc.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt; is responsible for managing courses. It performs CRUD operations on the Course model. It is responsible for creating, editing, deleting courses, and adding/removing teaching assistants to the course. The controller also returns a list of Teaching assistants associated with the course.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The problem statement requires us to re-implement the Course model and CoursesController in a Rails application, with the goal of managing courses by allowing admins to create, edit, update, and delete courses, as well as create copies of existing courses. The re-implementation should follow RESTful conventions, including appropriate HTTP response codes and status codes for each endpoint. We are required to write RSpec tests for the Course model and the CoursesController, covering all endpoints and including appropriate HTTP response codes for every method. Tests for the controller will be made compatible with RSwag to generate API documentation and test REST APIs from the Swagger UI.&lt;br /&gt;
&lt;br /&gt;
==Previous Work==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Based on the current functionality of Course model and controller we have defined the following RESTful endpoints with their Request type which would be implemented in the controller.&lt;br /&gt;
====Controller====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Request Type !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || action_allowed || HELPER FUNCTION || Determines whether the current user has permission to perform certain actions based on their role&lt;br /&gt;
|-&lt;br /&gt;
| 2 || auto_complete_for_user_name || GET || Provides an autocomplete feature for the form input when adding a TA&lt;br /&gt;
|-&lt;br /&gt;
| 3 || new || GET || Displays the form for creating a new course&lt;br /&gt;
|-&lt;br /&gt;
| 4 || edit|| GET || Method to get the course to edit&lt;br /&gt;
|-&lt;br /&gt;
| 5 || update || PUT || Method to update an existing course based on the form input and save the changes to database&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy || GET || Creates a new copy of an existing course with a new submission directory and saves it to the database&lt;br /&gt;
|-&lt;br /&gt;
| 7 || create || POST || Creates a new course based on the form input and saves it to database&lt;br /&gt;
|-&lt;br /&gt;
| 8 || delete || DELETE || Method to delete an existing course&lt;br /&gt;
|-&lt;br /&gt;
| 9 || view_teaching_assistant || GET || Displays all the teaching assistants for a course&lt;br /&gt;
|-&lt;br /&gt;
| 10 || add_ta || POST || Method to add teaching assistant to a course&lt;br /&gt;
|-&lt;br /&gt;
| 11 || remove_ta || POST || Method to remove teaching assistant from a course&lt;br /&gt;
|-&lt;br /&gt;
| 12 || set_course_fields || POST || Called in Update and Create methods to set the fields of course&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Model====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || get_teams || Returns any predefined teams associated with a particular course object&lt;br /&gt;
|-&lt;br /&gt;
| 2 || get_participants || Returns multiple records of course participants from database given parent_id and user_id&lt;br /&gt;
|-&lt;br /&gt;
| 3 || get_participant || Returns a single record course participant from Course Participant given parent_id&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add _participant || Add a new Course Participant to the course given user_name&lt;br /&gt;
|-&lt;br /&gt;
| 5 || copy_participants || Copies all the participants from a given assignment to the current course&lt;br /&gt;
|-&lt;br /&gt;
| 6 || user_on_team || Checks whether a given user is a member of any team associated with the course&lt;br /&gt;
|-&lt;br /&gt;
| 7 || path || Returns the course's submission directory&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
[[Image: UML.png]]&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
The Course model and controller will be tested using Rspec. FactoryBot will be utilized to create test fixtures and to build the required models. As the methods in the controller are defined as RESTful endpoints. The test take into consideration that the methods return the correct status codes for the output. Based on the current functionality of Course model and controller we have defined the following test which would implemented to test the reimplemented code of course model and controller. &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
'''Course Controller'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the action_allowed disallows all actions when current user is student.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the action_allowed allows all course actions when current user is instructor.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if create method returns a 201 Created status code if the resource is successfully created.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if create method returns a 422 Unprocessable Entity status code if the resource cannot be created due to validation errors.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Tests if the delete method returns a 204 No Content status code if the resource is successfully deleted.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Tests if the delete method returns a 404 Not Found status code if the resource cannot be found.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tests if the new method sets the private instance variable.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Tests if the update method returns a 200 OK status code if the resource is successfully updated.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Tests if the update method returns a 422 Unprocessable Entity status code if the resource cannot be updated due to validation errors.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Tests if the topic_name method returns the participant topic name when not nil.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Tests if the auto_complete_for_user_name method returns a list of users.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Tests if the copy method redirects to new course when new course id fetched successfully.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the view_teaching_assistants method returns list of TAs for the course.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the add_ta method returns a 200 OK status code if a TA added successfully to the course.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the add_ta method returns a 422 Unprocessable Entity status code if a TA cannot be added to the course.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the remove_ta method returns a 204 No Content status code if the ta is successfully removed from the course.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Tests if the remove_ta method returns a 404 Not Found status code if the ta cannot be found.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Tests if the set_course_fields method sets the course fields.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Course Model'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the model validates presence of name&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the model validates presence of directory_path&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if path method raises an error when there is no associated instructor.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if path method returns a directory when there is an associated instructor.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/ameyagv/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149372</id>
		<title>CSC/ECE 517/Spring 2023/E2332 Reimplement Courses (Refactor course.rb)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149372"/>
		<updated>2023-04-10T03:49:30Z</updated>

		<summary type="html">&lt;p&gt;Vspande: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails, which functions as a learning management software system. It has many different functions and abilities, including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and a list of operations that can be performed on the course model. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model and &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt;, which are the classes primarily addressed in this project, are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model stores information about the instructor and institution it belongs to, and it is associated with other models such as User, Assignment, etc. The course model is responsible for completing a variety of tasks, including returning the submission directory for the course, viewing students enrolled in the course, and adding a student to the course, etc.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt; is responsible for managing courses. It performs CRUD operations on the Course model. It is responsible for creating, editing, deleting courses, and adding/removing teaching assistants to the course. The controller also returns a list of Teaching assistants associated with the course.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The problem statement requires us to re-implement the Course model and CoursesController in a Rails application, with the goal of managing courses by allowing admins to create, edit, update, and delete courses, as well as create copies of existing courses. The re-implementation should follow RESTful conventions, including appropriate HTTP response codes and status codes for each endpoint. We are required to write RSpec tests for the Course model and the CoursesController, covering all endpoints and including appropriate HTTP response codes for every method. Tests for the controller will be made compatible with RSwag to generate API documentation and test REST APIs from the Swagger UI.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Based on the current functionality of Course model and controller we have defined the following RESTful endpoints with their Request type which would be implemented in the controller.&lt;br /&gt;
====Controller====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Request Type !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || action_allowed || HELPER FUNCTION || Determines whether the current user has permission to perform certain actions based on their role&lt;br /&gt;
|-&lt;br /&gt;
| 2 || auto_complete_for_user_name || GET || Provides an autocomplete feature for the form input when adding a TA&lt;br /&gt;
|-&lt;br /&gt;
| 3 || new || GET || Displays the form for creating a new course&lt;br /&gt;
|-&lt;br /&gt;
| 4 || edit|| GET || Method to get the course to edit&lt;br /&gt;
|-&lt;br /&gt;
| 5 || update || PUT || Method to update an existing course based on the form input and save the changes to database&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy || GET || Creates a new copy of an existing course with a new submission directory and saves it to the database&lt;br /&gt;
|-&lt;br /&gt;
| 7 || create || POST || Creates a new course based on the form input and saves it to database&lt;br /&gt;
|-&lt;br /&gt;
| 8 || delete || DELETE || Method to delete an existing course&lt;br /&gt;
|-&lt;br /&gt;
| 9 || view_teaching_assistant || GET || Displays all the teaching assistants for a course&lt;br /&gt;
|-&lt;br /&gt;
| 10 || add_ta || POST || Method to add teaching assistant to a course&lt;br /&gt;
|-&lt;br /&gt;
| 11 || remove_ta || POST || Method to remove teaching assistant from a course&lt;br /&gt;
|-&lt;br /&gt;
| 12 || set_course_fields || POST || Called in Update and Create methods to set the fields of course&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Model====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || get_teams || Returns any predefined teams associated with a particular course object&lt;br /&gt;
|-&lt;br /&gt;
| 2 || get_participants || Returns multiple records of course participants from database given parent_id and user_id&lt;br /&gt;
|-&lt;br /&gt;
| 3 || get_participant || Returns a single record course participant from Course Participant given parent_id&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add _participant || Add a new Course Participant to the course given user_name&lt;br /&gt;
|-&lt;br /&gt;
| 5 || copy_participants || Copies all the participants from a given assignment to the current course&lt;br /&gt;
|-&lt;br /&gt;
| 6 || user_on_team || Checks whether a given user is a member of any team associated with the course&lt;br /&gt;
|-&lt;br /&gt;
| 7 || path || Returns the course's submission directory&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
[[Image: UML.png]]&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
The Course model and controller will be tested using Rspec. FactoryBot will be utilized to create test fixtures and to build the required models. As the methods in the controller are defined as RESTful endpoints. The test take into consideration that the methods return the correct status codes for the output. Based on the current functionality of Course model and controller we have defined the following test which would implemented to test the reimplemented code of course model and controller. &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
'''Course Controller'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the action_allowed disallows all actions when current user is student.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the action_allowed allows all course actions when current user is instructor.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if create method returns a 201 Created status code if the resource is successfully created.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if create method returns a 422 Unprocessable Entity status code if the resource cannot be created due to validation errors.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Tests if the delete method returns a 204 No Content status code if the resource is successfully deleted.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Tests if the delete method returns a 404 Not Found status code if the resource cannot be found.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tests if the new method sets the private instance variable.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Tests if the update method returns a 200 OK status code if the resource is successfully updated.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Tests if the update method returns a 422 Unprocessable Entity status code if the resource cannot be updated due to validation errors.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Tests if the topic_name method returns the participant topic name when not nil.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Tests if the auto_complete_for_user_name method returns a list of users.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Tests if the copy method redirects to new course when new course id fetched successfully.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the view_teaching_assistants method returns list of TAs for the course.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the add_ta method returns a 200 OK status code if a TA added successfully to the course.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the add_ta method returns a 422 Unprocessable Entity status code if a TA cannot be added to the course.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the remove_ta method returns a 204 No Content status code if the ta is successfully removed from the course.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Tests if the remove_ta method returns a 404 Not Found status code if the ta cannot be found.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Tests if the set_course_fields method sets the course fields.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Course Model'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the model validates presence of name&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the model validates presence of directory_path&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if path method raises an error when there is no associated instructor.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if path method returns a directory when there is an associated instructor.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/ameyagv/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:UML.png&amp;diff=149371</id>
		<title>File:UML.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:UML.png&amp;diff=149371"/>
		<updated>2023-04-10T03:48:22Z</updated>

		<summary type="html">&lt;p&gt;Vspande: Vspande uploaded a new version of File:UML.png&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149370</id>
		<title>CSC/ECE 517/Spring 2023/E2332 Reimplement Courses (Refactor course.rb)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149370"/>
		<updated>2023-04-10T03:47:47Z</updated>

		<summary type="html">&lt;p&gt;Vspande: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails, which functions as a learning management software system. It has many different functions and abilities, including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and a list of operations that can be performed on the course model. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model and &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt;, which are the classes primarily addressed in this project, are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model stores information about the instructor and institution it belongs to, and it is associated with other models such as User, Assignment, etc. The course model is responsible for completing a variety of tasks, including returning the submission directory for the course, viewing students enrolled in the course, and adding a student to the course, etc.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt; is responsible for managing courses. It performs CRUD operations on the Course model. It is responsible for creating, editing, deleting courses, and adding/removing teaching assistants to the course. The controller also returns a list of Teaching assistants associated with the course.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The problem statement requires us to re-implement the Course model and CoursesController in a Rails application, with the goal of managing courses by allowing admins to create, edit, update, and delete courses, as well as create copies of existing courses. The re-implementation should follow RESTful conventions, including appropriate HTTP response codes and status codes for each endpoint. We are required to write RSpec tests for the Course model and the CoursesController, covering all endpoints and including appropriate HTTP response codes for every method. Tests for the controller will be made compatible with RSwag to generate API documentation and test REST APIs from the Swagger UI.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Based on the current functionality of Course model and controller we have defined the following RESTful endpoints with their Request type which would be implemented in the controller.&lt;br /&gt;
====Controller====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Request Type !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || action_allowed || HELPER FUNCTION || Determines whether the current user has permission to perform certain actions based on their role&lt;br /&gt;
|-&lt;br /&gt;
| 2 || auto_complete_for_user_name || GET || Provides an autocomplete feature for the form input when adding a TA&lt;br /&gt;
|-&lt;br /&gt;
| 3 || new || GET || Displays the form for creating a new course&lt;br /&gt;
|-&lt;br /&gt;
| 4 || edit|| GET || Method to get the course to edit&lt;br /&gt;
|-&lt;br /&gt;
| 5 || update || PUT || Method to update an existing course based on the form input and save the changes to database&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy || GET || Creates a new copy of an existing course with a new submission directory and saves it to the database&lt;br /&gt;
|-&lt;br /&gt;
| 7 || create || POST || Creates a new course based on the form input and saves it to database&lt;br /&gt;
|-&lt;br /&gt;
| 8 || delete || DELETE || Method to delete an existing course&lt;br /&gt;
|-&lt;br /&gt;
| 9 || view_teaching_assistant || GET || Displays all the teaching assistants for a course&lt;br /&gt;
|-&lt;br /&gt;
| 10 || add_ta || POST || Method to add teaching assistant to a course&lt;br /&gt;
|-&lt;br /&gt;
| 11 || remove_ta || POST || Method to remove teaching assistant from a course&lt;br /&gt;
|-&lt;br /&gt;
| 12 || set_course_fields || POST || Called in Update and Create methods to set the fields of course&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Model====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || get_teams || Returns any predefined teams associated with a particular course object&lt;br /&gt;
|-&lt;br /&gt;
| 2 || get_participants || Returns multiple records of course participants from database given parent_id and user_id&lt;br /&gt;
|-&lt;br /&gt;
| 3 || get_participant || Returns a single record course participant from Course Participant given parent_id&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add _participant || Add a new Course Participant to the course given user_name&lt;br /&gt;
|-&lt;br /&gt;
| 5 || copy_participants || Copies all the participants from a given assignment to the current course&lt;br /&gt;
|-&lt;br /&gt;
| 6 || user_on_team || Checks whether a given user is a member of any team associated with the course&lt;br /&gt;
|-&lt;br /&gt;
| 7 || path || Returns the course's submission directory&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
The Course model and controller will be tested using Rspec. FactoryBot will be utilized to create test fixtures and to build the required models. As the methods in the controller are defined as RESTful endpoints. The test take into consideration that the methods return the correct status codes for the output. Based on the current functionality of Course model and controller we have defined the following test which would implemented to test the reimplemented code of course model and controller. &lt;br /&gt;
&lt;br /&gt;
====Tests====&lt;br /&gt;
'''Course Controller'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the action_allowed disallows all actions when current user is student.&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the action_allowed allows all course actions when current user is instructor.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if create method returns a 201 Created status code if the resource is successfully created.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if create method returns a 422 Unprocessable Entity status code if the resource cannot be created due to validation errors.&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Tests if the delete method returns a 204 No Content status code if the resource is successfully deleted.&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Tests if the delete method returns a 404 Not Found status code if the resource cannot be found.&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tests if the new method sets the private instance variable.&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Tests if the update method returns a 200 OK status code if the resource is successfully updated.&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Tests if the update method returns a 422 Unprocessable Entity status code if the resource cannot be updated due to validation errors.&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Tests if the topic_name method returns the participant topic name when not nil.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Tests if the auto_complete_for_user_name method returns a list of users.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Tests if the copy method redirects to new course when new course id fetched successfully.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the view_teaching_assistants method returns list of TAs for the course.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the add_ta method returns a 200 OK status code if a TA added successfully to the course.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the add_ta method returns a 422 Unprocessable Entity status code if a TA cannot be added to the course.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the remove_ta method returns a 204 No Content status code if the ta is successfully removed from the course.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Tests if the remove_ta method returns a 404 Not Found status code if the ta cannot be found.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Tests if the set_course_fields method sets the course fields.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Course Model'''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the model validates presence of name&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the model validates presence of directory_path&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if path method raises an error when there is no associated instructor.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if path method returns a directory when there is an associated instructor.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/ameyagv/reimplementation-back-end&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149099</id>
		<title>CSC/ECE 517/Spring 2023/E2332 Reimplement Courses (Refactor course.rb)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149099"/>
		<updated>2023-04-07T20:32:03Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails, which functions as a learning management software system. It has many different functions and abilities, including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and a list of operations that can be performed on the course model. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model and &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt;, which are the classes primarily addressed in this project, are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; model stores information about the instructor and institution and is associated with other models such as User, CourseParticipant, CourseTeam, Assignment, AssignmentParticipant, and Notification. The course model is responsible for completing a variety of tasks, including returning course teams, returning the submission directory for the course, viewing participants enrolled in the course, adding a participant to the course, copying the Assignment Participants to Course Participants, and checking whether a user is part of any CourseTeam. The problem description lists code smells that need to be fixed. We fixed some issues, such as deleting the unused methods and renaming methods to indicate their action. The renaming problem required us to change a few methods calls where the function to be renamed was used. Also, to reduce the cognitive complexity of the copy_assignment_participants method, we created a method to separate the raising error functionality. Comments were added to indicate the action of the methods.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; is a subclass of the team class. CourseTeams are a type of team that an instructor can use throughout an entire semester, providing consistency in team membership over time. The course_team model is responsible for completing various tasks, including returning the course of the team, adding a participant to the CourseTeam, and copying the CourseTeam Participants to AssignmentTeam Participants. There are methods for importing and exporting data to/from CSV files for CourseTeam objects. The problem description lists code smells/issues that need to be fixed. The issues that we fixed were deleting unused methods, renaming methods, and changing method calls, changing rspec expectations, adding meaningful comments. To refactor methods, DRY principles were used. In addition, analogous changes were made in the assignment_team model.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
==Design Decisions==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Controller====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Request Type !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || action_allowed || HELPER FUNCTION || Determines whether the current user has permission to perform certain actions based on their role&lt;br /&gt;
|-&lt;br /&gt;
| 2 || auto_complete_for_user_name || GET || Provides an autocomplete feature for the form input when adding a TA&lt;br /&gt;
|-&lt;br /&gt;
| 3 || new || GET || Displays the form for creating a new course&lt;br /&gt;
|-&lt;br /&gt;
| 4 || edit|| GET || Method to get the course to edit&lt;br /&gt;
|-&lt;br /&gt;
| 5 || update || PUT || Method to update an existing course based on the form input and save the changes to database&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy || GET || Creates a new copy of an existing course with a new submission directory and saves it to the database&lt;br /&gt;
|-&lt;br /&gt;
| 7 || create || POST || Creates a new course based on the form input and saves it to database&lt;br /&gt;
|-&lt;br /&gt;
| 8 || delete || DELETE || Method to delete an existing course&lt;br /&gt;
|-&lt;br /&gt;
| 9 || view_teaching_assistant || GET || Displays all the teaching assistants for a course&lt;br /&gt;
|-&lt;br /&gt;
| 10 || add_ta || POST || Method to add teaching assistant to a course&lt;br /&gt;
|-&lt;br /&gt;
| 11 || remove_ta || POST || Method to remove teaching assistant from a course&lt;br /&gt;
|-&lt;br /&gt;
| 12 || set_course_fields || POST || Called in Update and Create methods to set the fields of course&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Model====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || get_teams || Returns any predefined teams associated with a particular course object&lt;br /&gt;
|-&lt;br /&gt;
| 2 || get_participants || Returns multiple records of course participants from database given parent_id and user_id&lt;br /&gt;
|-&lt;br /&gt;
| 3 || get_participant || Returns a single record course participant from Course Participant given parent_id&lt;br /&gt;
|-&lt;br /&gt;
| 4 || add _participant || Add a new Course Participant to the course given user_name&lt;br /&gt;
|-&lt;br /&gt;
| 5 || copy_participants || Copies all the participants from a given assignment to the current course&lt;br /&gt;
|-&lt;br /&gt;
| 6 || user_on_team || Checks whether a given user is a member of any team associated with the course&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the team method returns the team of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the leave_team method deletes a participant if no associations exist and force is nil&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if the leave_team method deletes a participant if no associations exist and force is true&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if the leave_team method deletes a participant with associations and force is true and there are multiple team users&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Tests if the name method returns the name of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Tests if the fullname method returns the full name of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tests if the handle method returns the handle of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Tests if the sort_by_name method returns a sorted list of participants in alphabetical order&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Tests if the topic_name method returns the participant topic name when nil&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Tests if the topic_name method returns the participant topic name when not nil.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Tests if the authorization method returns participant when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Tests if the authorization method returns reader when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the authorization method returns submitter when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the authorization method returns reviewer when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the authorization method returns submitter when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the authorization method returns reviewer when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Tests if it returns participant data in the correct format.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test if it exports the details of the participant correctly.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
What it does: The Course model and CoursesController is responsible for managing the courses. This system allows admin to create a new course, edit the course and update the existing course. It also allows you to create a copy of an existing course, etc.&lt;br /&gt;
&lt;br /&gt;
What needs to be done:&lt;br /&gt;
You have to exactly follow the reimplementation guidelines as stated on top and make sure that you have covered all the functionality that is required for the Courses. You will be responsible for the entire functionality of the Courses, the model and controller, and the detailed rspec test, testing all the pass and fail scenarios, for the rest endpoints are compulsory. &lt;br /&gt;
As mentioned in the guideline, take reference from the User (model &amp;amp; controller) implementation and look at roles_rspec.rb for the test, roles_rspec is not complete and there is potential for better testing but you can use that as a starting point.&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/ameyagv/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' &lt;br /&gt;
* '''VCL Server:'''&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149096</id>
		<title>CSC/ECE 517/Spring 2023/E2332 Reimplement Courses (Refactor course.rb)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149096"/>
		<updated>2023-04-07T20:16:49Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Controller */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails, which functions as a learning management software system. It has many different functions and abilities, including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and a list of operations that can be performed on the course model. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model and &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt;, which are the classes primarily addressed in this project, are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; model stores information about the instructor and institution and is associated with other models such as User, CourseParticipant, CourseTeam, Assignment, AssignmentParticipant, and Notification. The course model is responsible for completing a variety of tasks, including returning course teams, returning the submission directory for the course, viewing participants enrolled in the course, adding a participant to the course, copying the Assignment Participants to Course Participants, and checking whether a user is part of any CourseTeam. The problem description lists code smells that need to be fixed. We fixed some issues, such as deleting the unused methods and renaming methods to indicate their action. The renaming problem required us to change a few methods calls where the function to be renamed was used. Also, to reduce the cognitive complexity of the copy_assignment_participants method, we created a method to separate the raising error functionality. Comments were added to indicate the action of the methods.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; is a subclass of the team class. CourseTeams are a type of team that an instructor can use throughout an entire semester, providing consistency in team membership over time. The course_team model is responsible for completing various tasks, including returning the course of the team, adding a participant to the CourseTeam, and copying the CourseTeam Participants to AssignmentTeam Participants. There are methods for importing and exporting data to/from CSV files for CourseTeam objects. The problem description lists code smells/issues that need to be fixed. The issues that we fixed were deleting unused methods, renaming methods, and changing method calls, changing rspec expectations, adding meaningful comments. To refactor methods, DRY principles were used. In addition, analogous changes were made in the assignment_team model.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
==Design Decisions==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Controller====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Request Type !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || action_allowed || HELPER FUNCTION || Determines whether the current user has permission to perform certain actions based on their role&lt;br /&gt;
|-&lt;br /&gt;
| 2 || auto_complete_for_user_name || GET || Provides an autocomplete feature for the form input wen adding a TA&lt;br /&gt;
|-&lt;br /&gt;
| 3 || new || GET || Displays the form for creating a new course&lt;br /&gt;
|-&lt;br /&gt;
| 4 || edit|| GET || Method to get the course to edit&lt;br /&gt;
|-&lt;br /&gt;
| 5 || update || PUT || Method to update an existing course based on the form input and save the changes to database&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy || GET || Creates a new copy of an existing course with a new submission directory and saves it to the database&lt;br /&gt;
|-&lt;br /&gt;
| 7 || create || POST || Creates a new course based on the form input and saves it to database&lt;br /&gt;
|-&lt;br /&gt;
| 8 || delete || DELETE || Method to delete an existing course&lt;br /&gt;
|-&lt;br /&gt;
| 9 || view_teaching_assistant || GET || Displays all the teaching assistants for a course&lt;br /&gt;
|-&lt;br /&gt;
| 10 || add_ta || POST || Method to add teaching assistant to a course&lt;br /&gt;
|-&lt;br /&gt;
| 11 || remove_ta || POST || Method to remove teaching assistant from a course&lt;br /&gt;
|-&lt;br /&gt;
| 12 || set_course_fields || POST || Called in Update and Create methods to set the fields of course&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the team method returns the team of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the leave_team method deletes a participant if no associations exist and force is nil&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if the leave_team method deletes a participant if no associations exist and force is true&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if the leave_team method deletes a participant with associations and force is true and there are multiple team users&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Tests if the name method returns the name of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Tests if the fullname method returns the full name of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tests if the handle method returns the handle of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Tests if the sort_by_name method returns a sorted list of participants in alphabetical order&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Tests if the topic_name method returns the participant topic name when nil&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Tests if the topic_name method returns the participant topic name when not nil.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Tests if the authorization method returns participant when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Tests if the authorization method returns reader when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the authorization method returns submitter when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the authorization method returns reviewer when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the authorization method returns submitter when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the authorization method returns reviewer when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Tests if it returns participant data in the correct format.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test if it exports the details of the participant correctly.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
What it does: The Course model and CoursesController is responsible for managing the courses. This system allows admin to create a new course, edit the course and update the existing course. It also allows you to create a copy of an existing course, etc.&lt;br /&gt;
&lt;br /&gt;
What needs to be done:&lt;br /&gt;
You have to exactly follow the reimplementation guidelines as stated on top and make sure that you have covered all the functionality that is required for the Courses. You will be responsible for the entire functionality of the Courses, the model and controller, and the detailed rspec test, testing all the pass and fail scenarios, for the rest endpoints are compulsory. &lt;br /&gt;
As mentioned in the guideline, take reference from the User (model &amp;amp; controller) implementation and look at roles_rspec.rb for the test, roles_rspec is not complete and there is potential for better testing but you can use that as a starting point.&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/ameyagv/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' &lt;br /&gt;
* '''VCL Server:'''&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149095</id>
		<title>CSC/ECE 517/Spring 2023/E2332 Reimplement Courses (Refactor course.rb)</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2332_Reimplement_Courses_(Refactor_course.rb)&amp;diff=149095"/>
		<updated>2023-04-07T20:15:53Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails, which functions as a learning management software system. It has many different functions and abilities, including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and a list of operations that can be performed on the course model. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; model and &amp;lt;code&amp;gt;CoursesController&amp;lt;/code&amp;gt;, which are the classes primarily addressed in this project, are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; model stores information about the instructor and institution and is associated with other models such as User, CourseParticipant, CourseTeam, Assignment, AssignmentParticipant, and Notification. The course model is responsible for completing a variety of tasks, including returning course teams, returning the submission directory for the course, viewing participants enrolled in the course, adding a participant to the course, copying the Assignment Participants to Course Participants, and checking whether a user is part of any CourseTeam. The problem description lists code smells that need to be fixed. We fixed some issues, such as deleting the unused methods and renaming methods to indicate their action. The renaming problem required us to change a few methods calls where the function to be renamed was used. Also, to reduce the cognitive complexity of the copy_assignment_participants method, we created a method to separate the raising error functionality. Comments were added to indicate the action of the methods.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; is a subclass of the team class. CourseTeams are a type of team that an instructor can use throughout an entire semester, providing consistency in team membership over time. The course_team model is responsible for completing various tasks, including returning the course of the team, adding a participant to the CourseTeam, and copying the CourseTeam Participants to AssignmentTeam Participants. There are methods for importing and exporting data to/from CSV files for CourseTeam objects. The problem description lists code smells/issues that need to be fixed. The issues that we fixed were deleting unused methods, renaming methods, and changing method calls, changing rspec expectations, adding meaningful comments. To refactor methods, DRY principles were used. In addition, analogous changes were made in the assignment_team model.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
==Design Decisions==&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
====Controller====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Index !! Method !! Request Type !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || action_allowed || HELPER FUNCTION || Determines whether the current user has permission to perform certain actions based on their role&lt;br /&gt;
|-&lt;br /&gt;
| 2 || auto_complete_for_user_name || GET || Provides an autocomplete feature for the form input wen adding a TA&lt;br /&gt;
|-&lt;br /&gt;
| 3 || new || GET || Displays the form for creating a new course&lt;br /&gt;
|-&lt;br /&gt;
| 4 || edit|| GET || Method to get the course to edit&lt;br /&gt;
|-&lt;br /&gt;
| 5 || update || PUT || Method to update an existing course based on the form input and save the changes to database&lt;br /&gt;
|-&lt;br /&gt;
| 6 || copy || GET || Creates a new copy of an existing course with a new submission directory and saves it to the database&lt;br /&gt;
|-&lt;br /&gt;
| 7 || create || POST || Creates a new course based on the form input and saves it to database&lt;br /&gt;
|-&lt;br /&gt;
| 8 || delete || DELETE || Method to delete an existing course&lt;br /&gt;
|-&lt;br /&gt;
| 9 || view_teaching_assistant || GET || Displays all the teacu=hing assistants for a course&lt;br /&gt;
|-&lt;br /&gt;
| 10 || add_ta || POST || Method to add teaching assistant to a course&lt;br /&gt;
|-&lt;br /&gt;
| 11 || remove_ta || POST || Method to remove teaching assistant from a course&lt;br /&gt;
|-&lt;br /&gt;
| 12 || set_course_fields || POST || Called in Update and Create methods to set the fields of course&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
====Tests====&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:40px&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Test No. !! Description &lt;br /&gt;
|-&lt;br /&gt;
| 1 || Tests if the team method returns the team of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Tests if the leave_team method deletes a participant if no associations exist and force is nil&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Tests if the leave_team method deletes a participant if no associations exist and force is true&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Tests if the leave_team method deletes a participant with associations and force is true and there are multiple team users&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Tests if the name method returns the name of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Tests if the fullname method returns the full name of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Tests if the handle method returns the handle of the participant&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Tests if the sort_by_name method returns a sorted list of participants in alphabetical order&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Tests if the topic_name method returns the participant topic name when nil&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Tests if the topic_name method returns the participant topic name when not nil.&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Tests if the authorization method returns participant when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Tests if the authorization method returns reader when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the authorization method returns submitter when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the authorization method returns reviewer when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Tests if the authorization method returns submitter when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tests if the authorization method returns reviewer when no arguments are passed.&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Tests if it returns participant data in the correct format.&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Test if it exports the details of the participant correctly.&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
What it does: The Course model and CoursesController is responsible for managing the courses. This system allows admin to create a new course, edit the course and update the existing course. It also allows you to create a copy of an existing course, etc.&lt;br /&gt;
&lt;br /&gt;
What needs to be done:&lt;br /&gt;
You have to exactly follow the reimplementation guidelines as stated on top and make sure that you have covered all the functionality that is required for the Courses. You will be responsible for the entire functionality of the Courses, the model and controller, and the detailed rspec test, testing all the pass and fail scenarios, for the rest endpoints are compulsory. &lt;br /&gt;
As mentioned in the guideline, take reference from the User (model &amp;amp; controller) implementation and look at roles_rspec.rb for the test, roles_rspec is not complete and there is potential for better testing but you can use that as a starting point.&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/ameyagv/reimplementation-back-end&lt;br /&gt;
* '''Pull Request:''' &lt;br /&gt;
* '''VCL Server:'''&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=148542</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=148542"/>
		<updated>2023-03-28T01:51:50Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* CHANGES IN RSPEC FILES */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; model stores information about the instructor and institution and is associated with other models such as User, CourseParticipant, CourseTeam, Assignment, AssignmentParticipant, and Notification. The course model is responsible for completing a variety of tasks, including returning course teams, returning the submission directory for the course, viewing participants enrolled in the course, adding a participant to the course, copying the Assignment Participants to Course Participants, and checking whether a user is part of any CourseTeam. The problem description lists code smells that need to be fixed. We fixed some issues, such as deleting the unused methods and renaming methods to indicate their action. The renaming problem required us to change a few methods calls where the function to be renamed was used. Also, to reduce the cognitive complexity of the copy_assignment_participants method, we created a method to separate the raising error functionality. Comments were added to indicate the action of the methods.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; is a subclass of the team class. CourseTeams are a type of team that an instructor can use throughout an entire semester, providing consistency in team membership over time. The course_team model is responsible for completing various tasks, including returning the course of the team, adding a participant to the CourseTeam, and copying the CourseTeam Participants to AssignmentTeam Participants. There are methods for importing and exporting data to/from CSV files for CourseTeam objects. The problem description lists code smells/issues that need to be fixed. The issues that we fixed were deleting unused methods, renaming methods, and changing method calls, changing rspec expectations, adding meaningful comments. To refactor methods, DRY principles were used. In addition, analogous changes were made in the assignment_team model.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
== CHANGES IN MODEL FILES ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/pull/2548/commits/8fb9bf9a793b8c154bc2b640daa630624e008a86 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Created method &amp;lt;code&amp;gt;raise_errors&amp;lt;/code&amp;gt;&lt;br /&gt;
|To reduce Cognitive Complexity of method &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added Import Functionality  &lt;br /&gt;
|DESCRIPTIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/972c66e47fbc22965490cc4da3ae69a56d076d6b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/assignment_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method for AssignmentTeam &lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; for copying current AssignmentTeam to CourseTeam as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/b93df2590a7ab52f87a1df00512afe626fa81520 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added Import Functionality  &lt;br /&gt;
|DESCRIPTIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/2bae1785a15caede251f81517ecf944302f80d89 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added Import Functionality  &lt;br /&gt;
|DESCRIPTIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/53a86107644d3a0b0bef28a42d499a0b7b386ebb Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== CHANGES IN RSPEC FILES ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Import functionality changes&amp;lt;/code&amp;gt;&lt;br /&gt;
|Test cases are added to rspec file as well for import functionality changes.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/972c66e47fbc22965490cc4da3ae69a56d076d6b Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/assignment_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Import functionality changes&amp;lt;/code&amp;gt;&lt;br /&gt;
|Test cases are added to rspec file as well for import functionality changes.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/2bae1785a15caede251f81517ecf944302f80d89 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Import functionality changes&amp;lt;/code&amp;gt;&lt;br /&gt;
|Test cases are added to rspec file as well for import functionality changes.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/53a86107644d3a0b0bef28a42d499a0b7b386ebb#diff-638390a8686ba4d2e18c1fc9dfbef22271c8a02bb5d56bf78ded42e428fcf8b1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== CHANGES IN CONTROLLER FILES ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
-&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Coverage:&lt;br /&gt;
[[File:coverage_old.jpg|center|frame|Coverage of codebase before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:course_team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:course_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:assignment_team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;assignment_team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=148537</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=148537"/>
		<updated>2023-03-28T01:45:39Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* CHANGES IN MODEL FILES */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; model stores information about the instructor and institution and is associated with other models such as User, CourseParticipant, CourseTeam, Assignment, AssignmentParticipant, and Notification. The course model is responsible for completing a variety of tasks, including returning course teams, returning the submission directory for the course, viewing participants enrolled in the course, adding a participant to the course, copying the Assignment Participants to Course Participants, and checking whether a user is part of any CourseTeam. The problem description lists code smells that need to be fixed. We fixed some issues, such as deleting the unused methods and renaming methods to indicate their action. The renaming problem required us to change a few methods calls where the function to be renamed was used. Also, to reduce the cognitive complexity of the copy_assignment_participants method, we created a method to separate the raising error functionality. Comments were added to indicate the action of the methods.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; is a subclass of the team class. CourseTeams are a type of team that an instructor can use throughout an entire semester, providing consistency in team membership over time. The course_team model is responsible for completing various tasks, including returning the course of the team, adding a participant to the CourseTeam, and copying the CourseTeam Participants to AssignmentTeam Participants. There are methods for importing and exporting data to/from CSV files for CourseTeam objects. The problem description lists code smells/issues that need to be fixed. The issues that we fixed were deleting unused methods, renaming methods, and changing method calls, changing rspec expectations, adding meaningful comments. To refactor methods, DRY principles were used. In addition, analogous changes were made in the assignment_team model.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
== CHANGES IN MODEL FILES ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/pull/2548/commits/8fb9bf9a793b8c154bc2b640daa630624e008a86 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Created method &amp;lt;code&amp;gt;raise_errors&amp;lt;/code&amp;gt;&lt;br /&gt;
|To reduce Cognitive Complexity of method &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added Import Functionality  &lt;br /&gt;
|DESCRIPTIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/972c66e47fbc22965490cc4da3ae69a56d076d6b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/assignment_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method for AssignmentTeam &lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; for copying current AssignmentTeam to CourseTeam as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/b93df2590a7ab52f87a1df00512afe626fa81520 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added Import Functionality  &lt;br /&gt;
|DESCRIPTIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/2bae1785a15caede251f81517ecf944302f80d89 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added Import Functionality  &lt;br /&gt;
|DESCRIPTIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/53a86107644d3a0b0bef28a42d499a0b7b386ebb Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== CHANGES IN RSPEC FILES ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Import functionality changes&amp;lt;/code&amp;gt;&lt;br /&gt;
|Test cases are added to rspec file as well for import functionality changes.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/53a86107644d3a0b0bef28a42d499a0b7b386ebb#diff-638390a8686ba4d2e18c1fc9dfbef22271c8a02bb5d56bf78ded42e428fcf8b1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== CHANGES IN CONTROLLER FILES ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
-&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Coverage:&lt;br /&gt;
[[File:coverage_old.jpg|center|frame|Coverage of codebase before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:course_team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:course_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:assignment_team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;assignment_team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=148529</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=148529"/>
		<updated>2023-03-28T01:40:12Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; model stores information about the instructor and institution and is associated with other models such as User, CourseParticipant, CourseTeam, Assignment, AssignmentParticipant, and Notification. The course model is responsible for completing a variety of tasks, including returning course teams, returning the submission directory for the course, viewing participants enrolled in the course, adding a participant to the course, copying the Assignment Participants to Course Participants, and checking whether a user is part of any CourseTeam. The problem description lists code smells that need to be fixed. We fixed some issues, such as deleting the unused methods and renaming methods to indicate their action. The renaming problem required us to change a few methods calls where the function to be renamed was used. Also, to reduce the cognitive complexity of the copy_assignment_participants method, we created a method to separate the raising error functionality. Comments were added to indicate the action of the methods.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; is a subclass of the team class. CourseTeams are a type of team that an instructor can use throughout an entire semester, providing consistency in team membership over time. The course_team model is responsible for completing various tasks, including returning the course of the team, adding a participant to the CourseTeam, and copying the CourseTeam Participants to AssignmentTeam Participants. There are methods for importing and exporting data to/from CSV files for CourseTeam objects. The problem description lists code smells/issues that need to be fixed. The issues that we fixed were deleting unused methods, renaming methods, and changing method calls, changing rspec expectations, adding meaningful comments. To refactor methods, DRY principles were used. In addition, analogous changes were made in the assignment_team model.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
== CHANGES IN MODEL FILES ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/pull/2548/commits/8fb9bf9a793b8c154bc2b640daa630624e008a86 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Created method &amp;lt;code&amp;gt;raise_errors&amp;lt;/code&amp;gt;&lt;br /&gt;
|To reduce Cognitive Complexity of method &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/assignment_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method for AssignmentTeam &lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; for copying current AssignmentTeam to CourseTeam as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/b93df2590a7ab52f87a1df00512afe626fa81520 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added Import Functionality  &lt;br /&gt;
|DESCRIPTIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/53a86107644d3a0b0bef28a42d499a0b7b386ebb Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== CHANGES IN RSPEC FILES ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Import functionality changes&amp;lt;/code&amp;gt;&lt;br /&gt;
|Test cases are added to rspec file as well for import functionality changes.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/53a86107644d3a0b0bef28a42d499a0b7b386ebb#diff-638390a8686ba4d2e18c1fc9dfbef22271c8a02bb5d56bf78ded42e428fcf8b1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== CHANGES IN CONTROLLER FILES ==&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
-&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Coverage:&lt;br /&gt;
[[File:coverage_old.jpg|center|frame|Coverage of codebase before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:course_team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:course_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:assignment_team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;assignment_team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=148526</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=148526"/>
		<updated>2023-03-28T01:38:05Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; model stores information about the instructor and institution and is associated with other models such as User, CourseParticipant, CourseTeam, Assignment, AssignmentParticipant, and Notification. The course model is responsible for completing a variety of tasks, including returning course teams, returning the submission directory for the course, viewing participants enrolled in the course, adding a participant to the course, copying the Assignment Participants to Course Participants, and checking whether a user is part of any CourseTeam. The problem description lists code smells that need to be fixed. We fixed some issues, such as deleting the unused methods and renaming methods to indicate their action. The renaming problem required us to change a few methods calls where the function to be renamed was used. Also, to reduce the cognitive complexity of the copy_assignment_participants method, we created a method to separate the raising error functionality. Comments were added to indicate the action of the methods.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; is a subclass of the team class. CourseTeams are a type of team that an instructor can use throughout an entire semester, providing consistency in team membership over time. The course_team model is responsible for completing various tasks, including returning the course of the team, adding a participant to the CourseTeam, and copying the CourseTeam Participants to AssignmentTeam Participants. There are methods for importing and exporting data to/from CSV files for CourseTeam objects. The problem description lists code smells/issues that need to be fixed. The issues that we fixed were deleting unused methods, renaming methods, and changing method calls, changing rspec expectations, adding meaningful comments. To refactor methods, DRY principles were used. In addition, analogous changes were made in the assignment_team model.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== CHANGES IN MODEL FILES ===&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/pull/2548/commits/8fb9bf9a793b8c154bc2b640daa630624e008a86 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Created method &amp;lt;code&amp;gt;raise_errors&amp;lt;/code&amp;gt;&lt;br /&gt;
|To reduce Cognitive Complexity of method &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/assignment_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method for AssignmentTeam &lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; for copying current AssignmentTeam to CourseTeam as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/b93df2590a7ab52f87a1df00512afe626fa81520 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added Import Functionality  &lt;br /&gt;
|DESCRIPTIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/53a86107644d3a0b0bef28a42d499a0b7b386ebb Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== CHANGES IN RSPEC FILES ===&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Import functionality changes&amp;lt;/code&amp;gt;&lt;br /&gt;
|Test cases are added to rspec file as well for import functionality changes.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/53a86107644d3a0b0bef28a42d499a0b7b386ebb#diff-638390a8686ba4d2e18c1fc9dfbef22271c8a02bb5d56bf78ded42e428fcf8b1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== CHANGES IN CONTROLLER FILES ===&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
-&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Coverage:&lt;br /&gt;
[[File:coverage_old.jpg|center|frame|Coverage of codebase before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:course_team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:course_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:assignment_team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;assignment_team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:team_coverage.jpg|center|frame|Coverage of &amp;lt;code&amp;gt;team.rb&amp;lt;/code&amp;gt; before refactoring]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147970</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147970"/>
		<updated>2023-03-22T21:32:00Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; model stores information about the instructor and institution and is associated with other models such as User, CourseParticipant, CourseTeam, Assignment, AssignmentParticipant, and Notification. The course model is responsible for completing a variety of tasks, including returning course teams, returning the submission directory for the course, viewing participants enrolled in the course, adding a participant to the course, copying the Assignment Participants to Course Participants, and checking whether a user is part of any CourseTeam. The problem description lists code smells that need to be fixed. We fixed some issues, such as deleting the unused methods and renaming methods to indicate their action. The remaining problem required us to change a few method calls where the function to be renamed was used. Also, to reduce the cognitive complexity of the copy_assignment_participants method, we created a method to separate the raising error functionality. Comments were added to indicate the action of the method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes in Model Files ===&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/pull/2548/commits/8fb9bf9a793b8c154bc2b640daa630624e008a86 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Created method &amp;lt;code&amp;gt;raise_errors&amp;lt;/code&amp;gt;&lt;br /&gt;
|To reduce Cognitive Complexity of method &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/assignment_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method for AssignmentTeam &lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; for copying current AssignmentTeam to CourseTeam as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/b93df2590a7ab52f87a1df00512afe626fa81520 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes in RSPEC Files ===&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes in Controller Files ===&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147964</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147964"/>
		<updated>2023-03-22T21:27:25Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; model stores information about the instructor and institution and is associated with other models such as User, CourseParticipant, CourseTeam, Assignment, AssignmentParticipant, and Notification. The course model is responsible for completing a variety of tasks, including returning course teams, returning the submission directory for the course, viewing participants enrolled in the course, adding a participant to the course, copying the Assignment Participants to Course Participants, and checking whether a user is part of any CourseTeam. The problem description lists code smells that need to be fixed. We fixed some issues, such as deleting the unused methods and renaming methods to indicate their action. The remaining problem required us to change a few method calls where the function to be renamed was used. Also, to reduce the cognitive complexity of the copy_assignment_participants method, we created a method to separate the raising error functionality. Comments were added to indicate the action of the method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/assignment_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method for AssignmentTeam &lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; for copying current AssignmentTeam to CourseTeam as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/b93df2590a7ab52f87a1df00512afe626fa81520 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147908</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147908"/>
		<updated>2023-03-22T19:50:42Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/models/course_team_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147907</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147907"/>
		<updated>2023-03-22T19:50:31Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/models/course_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147906</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147906"/>
		<updated>2023-03-22T19:50:18Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/models/course_team.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147905</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147905"/>
		<updated>2023-03-22T19:48:33Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/models/course_team.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147904</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147904"/>
		<updated>2023-03-22T19:47:13Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/models/course_team.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call the assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; method as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|As this method is copying a CourseTeam to an AssignmentTeam, renamed it as &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;. A suggestion for copy method in AssignmentTeam would be to rename it as &amp;lt;code&amp;gt;copy_to_course_team&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-56ab3d3b28f0be68663223f0a5ef9daa5c8d106caca412481562272ab2edfae1 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147903</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147903"/>
		<updated>2023-03-22T19:40:06Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/models/course_team_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b#diff-8b753735f47ae84fdf88f7e9f15e08b8dd13ba1bc8fd16abad11148800aa8954 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147902</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147902"/>
		<updated>2023-03-22T19:37:02Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/controllers/teams_controller.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147901</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147901"/>
		<updated>2023-03-22T19:34:48Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/models/course_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147900</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147900"/>
		<updated>2023-03-22T19:34:31Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/models/course_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;, all these models were amended and as a result we need to update the tests. We added or amended tests in their respective .spec files&lt;br /&gt;
&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''course'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147897</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147897"/>
		<updated>2023-03-22T19:32:49Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/models/course_team_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
'''Note: Code Climate was not running on Expertiza's beta branch for the last four days of the project. We have done the best we could to removed extraneous lines and white spaces.''' &lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
All these models have an ::import method that we amended and as a result we need to update the tests. We added or amended tests in their respective .spec files to make sure that the ::import method has 100% coverage. &lt;br /&gt;
&lt;br /&gt;
*'''assignment_participant'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
*'''course_participant'''&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''team'''&lt;br /&gt;
*'''metareview_response_map'''&lt;br /&gt;
*'''review_response_map'''&lt;br /&gt;
*'''sign_up_topic'''&lt;br /&gt;
*'''user'''&lt;br /&gt;
&lt;br /&gt;
There is one failing test about exporting and we have not touched export functionality. There is another failing test about a review tab that we didn't touch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147896</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147896"/>
		<updated>2023-03-22T19:31:54Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/models/course_team_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
'''Note: Code Climate was not running on Expertiza's beta branch for the last four days of the project. We have done the best we could to removed extraneous lines and white spaces.''' &lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
All these models have an ::import method that we amended and as a result we need to update the tests. We added or amended tests in their respective .spec files to make sure that the ::import method has 100% coverage. &lt;br /&gt;
&lt;br /&gt;
*'''assignment_participant'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
*'''course_participant'''&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''team'''&lt;br /&gt;
*'''metareview_response_map'''&lt;br /&gt;
*'''review_response_map'''&lt;br /&gt;
*'''sign_up_topic'''&lt;br /&gt;
*'''user'''&lt;br /&gt;
&lt;br /&gt;
There is one failing test about exporting and we have not touched export functionality. There is another failing test about a review tab that we didn't touch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147895</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147895"/>
		<updated>2023-03-22T19:31:07Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/models/course_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
'''Note: Code Climate was not running on Expertiza's beta branch for the last four days of the project. We have done the best we could to removed extraneous lines and white spaces.''' &lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
All these models have an ::import method that we amended and as a result we need to update the tests. We added or amended tests in their respective .spec files to make sure that the ::import method has 100% coverage. &lt;br /&gt;
&lt;br /&gt;
*'''assignment_participant'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
*'''course_participant'''&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''team'''&lt;br /&gt;
*'''metareview_response_map'''&lt;br /&gt;
*'''review_response_map'''&lt;br /&gt;
*'''sign_up_topic'''&lt;br /&gt;
*'''user'''&lt;br /&gt;
&lt;br /&gt;
There is one failing test about exporting and we have not touched export functionality. There is another failing test about a review tab that we didn't touch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147894</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147894"/>
		<updated>2023-03-22T19:29:12Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/models/course_team.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|CourseTeam and AssignmentTeam inherit from Team class. The teams' table has an attribute &amp;lt;code&amp;gt;parent_id&amp;lt;/code&amp;gt; that helps determine whether the team is AssigmentTeam or CourseTeam. Thus, there is no need for &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; in the CourseTeam class and no need for &amp;lt;code&amp;gt;course_id&amp;lt;/code&amp;gt; in AssignmentTeam class. It will be a bad coding practice to call assignment_id method on the CourseTeam object, calling the course_id method on the AssignmentTeam object as it would be inappropriate.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/ef9727542999c6cdbf2334f5b62ebb30fbfe8cdd Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
'''Note: Code Climate was not running on Expertiza's beta branch for the last four days of the project. We have done the best we could to removed extraneous lines and white spaces.''' &lt;br /&gt;
&lt;br /&gt;
All the suggested changes were made to &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;course_team.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
All these models have an ::import method that we amended and as a result we need to update the tests. We added or amended tests in their respective .spec files to make sure that the ::import method has 100% coverage. &lt;br /&gt;
&lt;br /&gt;
*'''assignment_participant'''&lt;br /&gt;
*'''assignment_team'''&lt;br /&gt;
*'''course_participant'''&lt;br /&gt;
*'''course_team'''&lt;br /&gt;
*'''team'''&lt;br /&gt;
*'''metareview_response_map'''&lt;br /&gt;
*'''review_response_map'''&lt;br /&gt;
*'''sign_up_topic'''&lt;br /&gt;
*'''user'''&lt;br /&gt;
&lt;br /&gt;
There is one failing test about exporting and we have not touched export functionality. There is another failing test about a review tab that we didn't touch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147892</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147892"/>
		<updated>2023-03-22T19:22:00Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/models/course_team.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;assignment_id&amp;lt;/code&amp;gt; &lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147889</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147889"/>
		<updated>2023-03-22T19:07:27Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/models/course.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147886</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147886"/>
		<updated>2023-03-22T19:05:27Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/models/course.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Removed &amp;lt;code&amp;gt;add_member&amp;lt;/code&amp;gt; method from &amp;lt;code&amp;gt;course_team&amp;lt;/code&amp;gt; model&lt;br /&gt;
|Assignment_team and Course_team are subclasses of Team. Both should follow the similar logic of adding members of respective teams. As of for, add_participants, usage is different for course.rb and course_team.rb, hence it should be present in both. However, to make the code more consistent among classes, team, course_team, and assignment_team, the add_member method should only be present in the team class.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147769</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147769"/>
		<updated>2023-03-22T03:57:53Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/models/course_team.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/7c1ae764d2d64e0246422934f292b9b2fe43a031 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147723</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147723"/>
		<updated>2023-03-22T01:47:16Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/controllers/teams_controller.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_to_assignment_team&amp;lt;/code&amp;gt; &lt;br /&gt;
|The change was directly related to changes of copy method in &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/372b8d44dfbc3b29c07f41500a5cc53d23cf577b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147715</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147715"/>
		<updated>2023-03-22T01:34:53Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/models/course_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method test case&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147714</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147714"/>
		<updated>2023-03-22T01:33:30Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/models/course_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; in RSPEC&lt;br /&gt;
|Renamed the respective method of &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt;in rspec file as well.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147713</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147713"/>
		<updated>2023-03-22T01:30:13Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/models/course.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Renamed &amp;lt;code&amp;gt;copy_participants&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;copy_assignment_participants&amp;lt;/code&amp;gt; which makes more sense and a clear idea of how method works and what is the purpose of method.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/5177376c0f9a4f1890f49879bbbbfee0b28b8263 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147703</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147703"/>
		<updated>2023-03-22T01:19:37Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147699</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147699"/>
		<updated>2023-03-22T01:13:32Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147697</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147697"/>
		<updated>2023-03-22T01:12:21Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/controllers/auth_controller_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_team_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147696</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147696"/>
		<updated>2023-03-22T01:11:45Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to app/controllers/auth_controller.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course_team.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147695</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147695"/>
		<updated>2023-03-22T01:10:14Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/factories/password_retrieval_factory.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/teams_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/auth_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147693</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147693"/>
		<updated>2023-03-22T00:54:46Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Contributors to this project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/factories/password_retrieval_factory.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/auth_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147691</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147691"/>
		<updated>2023-03-22T00:51:25Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Relevant Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/factories/password_retrieval_factory.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/auth_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/kartikrawool/expertiza/tree/refactor_course&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2548&lt;br /&gt;
* '''VCL Server:''' http://152.7.178.105:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Grey Files (unityid: mgfiles, github: greyfiles)&lt;br /&gt;
* Colin O'Dowd (unityid: cdodowd, github: colin-odowd)&lt;br /&gt;
* Pradyumna Khawas (unityid: ppkhawas, github: therealppk)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147685</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147685"/>
		<updated>2023-03-22T00:42:17Z</updated>

		<summary type="html">&lt;p&gt;Vspande: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/factories/password_retrieval_factory.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/auth_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/greyfiles/expertiza&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2460&lt;br /&gt;
* '''VCL Server:''' http://152.7.98.115:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Grey Files (unityid: mgfiles, github: greyfiles)&lt;br /&gt;
* Colin O'Dowd (unityid: cdodowd, github: colin-odowd)&lt;br /&gt;
* Pradyumna Khawas (unityid: ppkhawas, github: therealppk)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147419</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147419"/>
		<updated>2023-03-19T17:23:00Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt; and not from anywhere else. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/6403edc25cf0edde623da63f23d92a1a57d67375 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/factories/password_retrieval_factory.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/auth_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
'''Everything in the testing segment was beyond the scope of our work. However, we wanted to validate our code through RSpec testing before merging into the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; Expertiza branch. In the second submission phase, we plan to further enhance the testing suite of the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; through factories and fixtures.''' &lt;br /&gt;
&lt;br /&gt;
=== Test Plan - Manual/System Test Cases ===&lt;br /&gt;
Along with the unit tests that we have written to test our files, we conducted a few system tests manually to verify the functionality works as expected. The &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; is difficult for us to test because we don't have access to the email used to make the sample account, but the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; is very testable. Below is the tests we completed listed in the order of completion.&lt;br /&gt;
&lt;br /&gt;
==== 1) Test instructor login &amp;amp; redirect to home page ====&lt;br /&gt;
When navigating to the expertiza website, our branch correctly displayed the login page as shown below.&lt;br /&gt;
[[File:before_login.png|center|border|Form shown to the user before logging in to expertiza]]&lt;br /&gt;
After typing in the sample login credentials of &amp;quot;instructor6&amp;quot; and &amp;quot;password,&amp;quot; the user is then correctly logged in and redirected to the home page for instructors shown below.&lt;br /&gt;
[[File:after_login.png|center|border|1400px|Page shown to the user after logging in to expertiza]]&lt;br /&gt;
==== 2) Test instructor logout &amp;amp; redirect to login page ====&lt;br /&gt;
Then, when the user clicks the logout button, they are correctly logged out and redirected once again to the login page as shown below.&lt;br /&gt;
[[File:after_logout.png|center|border|Form shown to the user after logging out of expertiza]]&lt;br /&gt;
==== 3) Test incorrect login ====&lt;br /&gt;
When the user attempts to login but enters the incorrect login information of &amp;quot;instructor6&amp;quot; and &amp;quot;incorrect,&amp;quot; the user is shown the error message and then correctly redirected to the forgot password page shown below.&lt;br /&gt;
[[File:after_incorrect_login.png|center|border|1400px|Form shown to the user after an incorrect login attempt to expertiza]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;auth_controller_.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_auth_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After making all of the above changes to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;, we ran the rspec tests for the controller again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_refactor_auth_controller.png|center|frame|rspec tests continuing to all pass after completing the refactoring]]&lt;br /&gt;
&lt;br /&gt;
We have successfully preserved the passing tests after the improvements we made to the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. Next we looked at the existing tests to see if they could be improved. As listed in the files changed above, there were a few improvements to be made to &amp;lt;code&amp;gt;auth_controller_spec.rb&amp;lt;/code&amp;gt;. We improved a check for redirecting the user after logging in and added two tests to make sure the role cache was being rebuilt after both setting the current role and clearing the user info. We ran the tests again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_improving_auth_controller_spec.png|center|frame|rspec tests continuing to all pass after improving and adding to the auth_controller tests]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 91.94% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:coverage_before.png|center|frame|rspec test coverage report before the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
This is already a good coverage but after my changes I wanted to ensure my changes were also tested thoroughly. After adding tests, the tests covered 95.24% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. It improved slightly to be an even better coverage.&lt;br /&gt;
[[File:coverage_after.png|center|frame|rspec test coverage report after the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;passsword_retrieval_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_password_retrieval_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 63.3% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_before.png|center|frame|rspec test coverage report before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After adding tests, the tests covered 91.1% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_after.png|center|frame|rspec test coverage report after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
We implemented factories in the rspec test file to improve modularity and code readability. Factories provide more flexibility in generating models to meet the requirements of the test, as opposed to fixtures. As you can see from the below images, the code is significantly cleaner as many lines of hardcoded strings have been removed. &lt;br /&gt;
[[File:prefactory.png|center|frame|rspec tests before factories were implemented]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:postfactory.png|center|frame|rspec tests after factories were implemented]]&lt;br /&gt;
&lt;br /&gt;
The below image shows the output of the following command after all tests were added: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:After refactor password retrieval controller.png|center|frame|rspec tests all passing after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/greyfiles/expertiza&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2460&lt;br /&gt;
* '''VCL Server:''' http://152.7.98.115:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Grey Files (unityid: mgfiles, github: greyfiles)&lt;br /&gt;
* Colin O'Dowd (unityid: cdodowd, github: colin-odowd)&lt;br /&gt;
* Pradyumna Khawas (unityid: ppkhawas, github: therealppk)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147418</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147418"/>
		<updated>2023-03-19T17:21:55Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Changes to spec/controllers/password_retrieval_controller_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt;. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/models/course_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_paprticipant&amp;lt;/code&amp;gt; method&lt;br /&gt;
|Removed the test case for &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method as the method was not used anywhere else in the code.&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/factories/password_retrieval_factory.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/auth_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
'''Everything in the testing segment was beyond the scope of our work. However, we wanted to validate our code through RSpec testing before merging into the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; Expertiza branch. In the second submission phase, we plan to further enhance the testing suite of the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; through factories and fixtures.''' &lt;br /&gt;
&lt;br /&gt;
=== Test Plan - Manual/System Test Cases ===&lt;br /&gt;
Along with the unit tests that we have written to test our files, we conducted a few system tests manually to verify the functionality works as expected. The &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; is difficult for us to test because we don't have access to the email used to make the sample account, but the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; is very testable. Below is the tests we completed listed in the order of completion.&lt;br /&gt;
&lt;br /&gt;
==== 1) Test instructor login &amp;amp; redirect to home page ====&lt;br /&gt;
When navigating to the expertiza website, our branch correctly displayed the login page as shown below.&lt;br /&gt;
[[File:before_login.png|center|border|Form shown to the user before logging in to expertiza]]&lt;br /&gt;
After typing in the sample login credentials of &amp;quot;instructor6&amp;quot; and &amp;quot;password,&amp;quot; the user is then correctly logged in and redirected to the home page for instructors shown below.&lt;br /&gt;
[[File:after_login.png|center|border|1400px|Page shown to the user after logging in to expertiza]]&lt;br /&gt;
==== 2) Test instructor logout &amp;amp; redirect to login page ====&lt;br /&gt;
Then, when the user clicks the logout button, they are correctly logged out and redirected once again to the login page as shown below.&lt;br /&gt;
[[File:after_logout.png|center|border|Form shown to the user after logging out of expertiza]]&lt;br /&gt;
==== 3) Test incorrect login ====&lt;br /&gt;
When the user attempts to login but enters the incorrect login information of &amp;quot;instructor6&amp;quot; and &amp;quot;incorrect,&amp;quot; the user is shown the error message and then correctly redirected to the forgot password page shown below.&lt;br /&gt;
[[File:after_incorrect_login.png|center|border|1400px|Form shown to the user after an incorrect login attempt to expertiza]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;auth_controller_.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_auth_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After making all of the above changes to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;, we ran the rspec tests for the controller again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_refactor_auth_controller.png|center|frame|rspec tests continuing to all pass after completing the refactoring]]&lt;br /&gt;
&lt;br /&gt;
We have successfully preserved the passing tests after the improvements we made to the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. Next we looked at the existing tests to see if they could be improved. As listed in the files changed above, there were a few improvements to be made to &amp;lt;code&amp;gt;auth_controller_spec.rb&amp;lt;/code&amp;gt;. We improved a check for redirecting the user after logging in and added two tests to make sure the role cache was being rebuilt after both setting the current role and clearing the user info. We ran the tests again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_improving_auth_controller_spec.png|center|frame|rspec tests continuing to all pass after improving and adding to the auth_controller tests]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 91.94% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:coverage_before.png|center|frame|rspec test coverage report before the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
This is already a good coverage but after my changes I wanted to ensure my changes were also tested thoroughly. After adding tests, the tests covered 95.24% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. It improved slightly to be an even better coverage.&lt;br /&gt;
[[File:coverage_after.png|center|frame|rspec test coverage report after the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;passsword_retrieval_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_password_retrieval_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 63.3% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_before.png|center|frame|rspec test coverage report before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After adding tests, the tests covered 91.1% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_after.png|center|frame|rspec test coverage report after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
We implemented factories in the rspec test file to improve modularity and code readability. Factories provide more flexibility in generating models to meet the requirements of the test, as opposed to fixtures. As you can see from the below images, the code is significantly cleaner as many lines of hardcoded strings have been removed. &lt;br /&gt;
[[File:prefactory.png|center|frame|rspec tests before factories were implemented]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:postfactory.png|center|frame|rspec tests after factories were implemented]]&lt;br /&gt;
&lt;br /&gt;
The below image shows the output of the following command after all tests were added: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:After refactor password retrieval controller.png|center|frame|rspec tests all passing after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/greyfiles/expertiza&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2460&lt;br /&gt;
* '''VCL Server:''' http://152.7.98.115:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Grey Files (unityid: mgfiles, github: greyfiles)&lt;br /&gt;
* Colin O'Dowd (unityid: cdodowd, github: colin-odowd)&lt;br /&gt;
* Pradyumna Khawas (unityid: ppkhawas, github: therealppk)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147417</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147417"/>
		<updated>2023-03-19T17:12:35Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt;. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; method&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; method. We wanted to enhance the test suite of this controller by increasing the coverage of its Rspec tests.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/a90b1aada9878c7cdf7319dd022432cca8eadd2f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/factories/password_retrieval_factory.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/auth_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
'''Everything in the testing segment was beyond the scope of our work. However, we wanted to validate our code through RSpec testing before merging into the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; Expertiza branch. In the second submission phase, we plan to further enhance the testing suite of the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; through factories and fixtures.''' &lt;br /&gt;
&lt;br /&gt;
=== Test Plan - Manual/System Test Cases ===&lt;br /&gt;
Along with the unit tests that we have written to test our files, we conducted a few system tests manually to verify the functionality works as expected. The &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; is difficult for us to test because we don't have access to the email used to make the sample account, but the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; is very testable. Below is the tests we completed listed in the order of completion.&lt;br /&gt;
&lt;br /&gt;
==== 1) Test instructor login &amp;amp; redirect to home page ====&lt;br /&gt;
When navigating to the expertiza website, our branch correctly displayed the login page as shown below.&lt;br /&gt;
[[File:before_login.png|center|border|Form shown to the user before logging in to expertiza]]&lt;br /&gt;
After typing in the sample login credentials of &amp;quot;instructor6&amp;quot; and &amp;quot;password,&amp;quot; the user is then correctly logged in and redirected to the home page for instructors shown below.&lt;br /&gt;
[[File:after_login.png|center|border|1400px|Page shown to the user after logging in to expertiza]]&lt;br /&gt;
==== 2) Test instructor logout &amp;amp; redirect to login page ====&lt;br /&gt;
Then, when the user clicks the logout button, they are correctly logged out and redirected once again to the login page as shown below.&lt;br /&gt;
[[File:after_logout.png|center|border|Form shown to the user after logging out of expertiza]]&lt;br /&gt;
==== 3) Test incorrect login ====&lt;br /&gt;
When the user attempts to login but enters the incorrect login information of &amp;quot;instructor6&amp;quot; and &amp;quot;incorrect,&amp;quot; the user is shown the error message and then correctly redirected to the forgot password page shown below.&lt;br /&gt;
[[File:after_incorrect_login.png|center|border|1400px|Form shown to the user after an incorrect login attempt to expertiza]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;auth_controller_.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_auth_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After making all of the above changes to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;, we ran the rspec tests for the controller again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_refactor_auth_controller.png|center|frame|rspec tests continuing to all pass after completing the refactoring]]&lt;br /&gt;
&lt;br /&gt;
We have successfully preserved the passing tests after the improvements we made to the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. Next we looked at the existing tests to see if they could be improved. As listed in the files changed above, there were a few improvements to be made to &amp;lt;code&amp;gt;auth_controller_spec.rb&amp;lt;/code&amp;gt;. We improved a check for redirecting the user after logging in and added two tests to make sure the role cache was being rebuilt after both setting the current role and clearing the user info. We ran the tests again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_improving_auth_controller_spec.png|center|frame|rspec tests continuing to all pass after improving and adding to the auth_controller tests]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 91.94% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:coverage_before.png|center|frame|rspec test coverage report before the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
This is already a good coverage but after my changes I wanted to ensure my changes were also tested thoroughly. After adding tests, the tests covered 95.24% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. It improved slightly to be an even better coverage.&lt;br /&gt;
[[File:coverage_after.png|center|frame|rspec test coverage report after the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;passsword_retrieval_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_password_retrieval_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 63.3% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_before.png|center|frame|rspec test coverage report before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After adding tests, the tests covered 91.1% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_after.png|center|frame|rspec test coverage report after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
We implemented factories in the rspec test file to improve modularity and code readability. Factories provide more flexibility in generating models to meet the requirements of the test, as opposed to fixtures. As you can see from the below images, the code is significantly cleaner as many lines of hardcoded strings have been removed. &lt;br /&gt;
[[File:prefactory.png|center|frame|rspec tests before factories were implemented]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:postfactory.png|center|frame|rspec tests after factories were implemented]]&lt;br /&gt;
&lt;br /&gt;
The below image shows the output of the following command after all tests were added: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:After refactor password retrieval controller.png|center|frame|rspec tests all passing after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/greyfiles/expertiza&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2460&lt;br /&gt;
* '''VCL Server:''' http://152.7.98.115:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Grey Files (unityid: mgfiles, github: greyfiles)&lt;br /&gt;
* Colin O'Dowd (unityid: cdodowd, github: colin-odowd)&lt;br /&gt;
* Pradyumna Khawas (unityid: ppkhawas, github: therealppk)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147416</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147416"/>
		<updated>2023-03-19T17:11:34Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Checked and Removed &amp;lt;code&amp;gt;get_participant&amp;lt;/code&amp;gt; method name to &lt;br /&gt;
|Checked the usage of Method through IDE whether the function is used, the only call was from &amp;lt;code&amp;gt;course_spec.rb&amp;lt;/code&amp;gt;. Hence, removed from &amp;lt;code&amp;gt;course.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
|[https://github.com/kartikrawool/expertiza/commit/63c62027d8cb3aebe281a6152113632aafc444ec Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; method&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; method. We wanted to enhance the test suite of this controller by increasing the coverage of its Rspec tests.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/a90b1aada9878c7cdf7319dd022432cca8eadd2f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/factories/password_retrieval_factory.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/auth_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
'''Everything in the testing segment was beyond the scope of our work. However, we wanted to validate our code through RSpec testing before merging into the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; Expertiza branch. In the second submission phase, we plan to further enhance the testing suite of the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; through factories and fixtures.''' &lt;br /&gt;
&lt;br /&gt;
=== Test Plan - Manual/System Test Cases ===&lt;br /&gt;
Along with the unit tests that we have written to test our files, we conducted a few system tests manually to verify the functionality works as expected. The &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; is difficult for us to test because we don't have access to the email used to make the sample account, but the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; is very testable. Below is the tests we completed listed in the order of completion.&lt;br /&gt;
&lt;br /&gt;
==== 1) Test instructor login &amp;amp; redirect to home page ====&lt;br /&gt;
When navigating to the expertiza website, our branch correctly displayed the login page as shown below.&lt;br /&gt;
[[File:before_login.png|center|border|Form shown to the user before logging in to expertiza]]&lt;br /&gt;
After typing in the sample login credentials of &amp;quot;instructor6&amp;quot; and &amp;quot;password,&amp;quot; the user is then correctly logged in and redirected to the home page for instructors shown below.&lt;br /&gt;
[[File:after_login.png|center|border|1400px|Page shown to the user after logging in to expertiza]]&lt;br /&gt;
==== 2) Test instructor logout &amp;amp; redirect to login page ====&lt;br /&gt;
Then, when the user clicks the logout button, they are correctly logged out and redirected once again to the login page as shown below.&lt;br /&gt;
[[File:after_logout.png|center|border|Form shown to the user after logging out of expertiza]]&lt;br /&gt;
==== 3) Test incorrect login ====&lt;br /&gt;
When the user attempts to login but enters the incorrect login information of &amp;quot;instructor6&amp;quot; and &amp;quot;incorrect,&amp;quot; the user is shown the error message and then correctly redirected to the forgot password page shown below.&lt;br /&gt;
[[File:after_incorrect_login.png|center|border|1400px|Form shown to the user after an incorrect login attempt to expertiza]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;auth_controller_.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_auth_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After making all of the above changes to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;, we ran the rspec tests for the controller again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_refactor_auth_controller.png|center|frame|rspec tests continuing to all pass after completing the refactoring]]&lt;br /&gt;
&lt;br /&gt;
We have successfully preserved the passing tests after the improvements we made to the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. Next we looked at the existing tests to see if they could be improved. As listed in the files changed above, there were a few improvements to be made to &amp;lt;code&amp;gt;auth_controller_spec.rb&amp;lt;/code&amp;gt;. We improved a check for redirecting the user after logging in and added two tests to make sure the role cache was being rebuilt after both setting the current role and clearing the user info. We ran the tests again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_improving_auth_controller_spec.png|center|frame|rspec tests continuing to all pass after improving and adding to the auth_controller tests]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 91.94% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:coverage_before.png|center|frame|rspec test coverage report before the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
This is already a good coverage but after my changes I wanted to ensure my changes were also tested thoroughly. After adding tests, the tests covered 95.24% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. It improved slightly to be an even better coverage.&lt;br /&gt;
[[File:coverage_after.png|center|frame|rspec test coverage report after the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;passsword_retrieval_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_password_retrieval_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 63.3% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_before.png|center|frame|rspec test coverage report before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After adding tests, the tests covered 91.1% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_after.png|center|frame|rspec test coverage report after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
We implemented factories in the rspec test file to improve modularity and code readability. Factories provide more flexibility in generating models to meet the requirements of the test, as opposed to fixtures. As you can see from the below images, the code is significantly cleaner as many lines of hardcoded strings have been removed. &lt;br /&gt;
[[File:prefactory.png|center|frame|rspec tests before factories were implemented]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:postfactory.png|center|frame|rspec tests after factories were implemented]]&lt;br /&gt;
&lt;br /&gt;
The below image shows the output of the following command after all tests were added: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:After refactor password retrieval controller.png|center|frame|rspec tests all passing after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/greyfiles/expertiza&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2460&lt;br /&gt;
* '''VCL Server:''' http://152.7.98.115:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Grey Files (unityid: mgfiles, github: greyfiles)&lt;br /&gt;
* Colin O'Dowd (unityid: cdodowd, github: colin-odowd)&lt;br /&gt;
* Pradyumna Khawas (unityid: ppkhawas, github: therealppk)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147415</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147415"/>
		<updated>2023-03-19T17:01:24Z</updated>

		<summary type="html">&lt;p&gt;Vspande: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/models/course.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated &amp;lt;code&amp;gt;check_reset_url&amp;lt;/code&amp;gt; method name to &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The method validates that the password reset token is valid and present. The updated method name provides a more functionally descriptive name. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; method&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; method. We wanted to enhance the test suite of this controller by increasing the coverage of its Rspec tests.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/a90b1aada9878c7cdf7319dd022432cca8eadd2f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/factories/password_retrieval_factory.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/auth_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
'''Everything in the testing segment was beyond the scope of our work. However, we wanted to validate our code through RSpec testing before merging into the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; Expertiza branch. In the second submission phase, we plan to further enhance the testing suite of the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; through factories and fixtures.''' &lt;br /&gt;
&lt;br /&gt;
=== Test Plan - Manual/System Test Cases ===&lt;br /&gt;
Along with the unit tests that we have written to test our files, we conducted a few system tests manually to verify the functionality works as expected. The &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; is difficult for us to test because we don't have access to the email used to make the sample account, but the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; is very testable. Below is the tests we completed listed in the order of completion.&lt;br /&gt;
&lt;br /&gt;
==== 1) Test instructor login &amp;amp; redirect to home page ====&lt;br /&gt;
When navigating to the expertiza website, our branch correctly displayed the login page as shown below.&lt;br /&gt;
[[File:before_login.png|center|border|Form shown to the user before logging in to expertiza]]&lt;br /&gt;
After typing in the sample login credentials of &amp;quot;instructor6&amp;quot; and &amp;quot;password,&amp;quot; the user is then correctly logged in and redirected to the home page for instructors shown below.&lt;br /&gt;
[[File:after_login.png|center|border|1400px|Page shown to the user after logging in to expertiza]]&lt;br /&gt;
==== 2) Test instructor logout &amp;amp; redirect to login page ====&lt;br /&gt;
Then, when the user clicks the logout button, they are correctly logged out and redirected once again to the login page as shown below.&lt;br /&gt;
[[File:after_logout.png|center|border|Form shown to the user after logging out of expertiza]]&lt;br /&gt;
==== 3) Test incorrect login ====&lt;br /&gt;
When the user attempts to login but enters the incorrect login information of &amp;quot;instructor6&amp;quot; and &amp;quot;incorrect,&amp;quot; the user is shown the error message and then correctly redirected to the forgot password page shown below.&lt;br /&gt;
[[File:after_incorrect_login.png|center|border|1400px|Form shown to the user after an incorrect login attempt to expertiza]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;auth_controller_.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_auth_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After making all of the above changes to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;, we ran the rspec tests for the controller again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_refactor_auth_controller.png|center|frame|rspec tests continuing to all pass after completing the refactoring]]&lt;br /&gt;
&lt;br /&gt;
We have successfully preserved the passing tests after the improvements we made to the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. Next we looked at the existing tests to see if they could be improved. As listed in the files changed above, there were a few improvements to be made to &amp;lt;code&amp;gt;auth_controller_spec.rb&amp;lt;/code&amp;gt;. We improved a check for redirecting the user after logging in and added two tests to make sure the role cache was being rebuilt after both setting the current role and clearing the user info. We ran the tests again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_improving_auth_controller_spec.png|center|frame|rspec tests continuing to all pass after improving and adding to the auth_controller tests]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 91.94% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:coverage_before.png|center|frame|rspec test coverage report before the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
This is already a good coverage but after my changes I wanted to ensure my changes were also tested thoroughly. After adding tests, the tests covered 95.24% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. It improved slightly to be an even better coverage.&lt;br /&gt;
[[File:coverage_after.png|center|frame|rspec test coverage report after the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;passsword_retrieval_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_password_retrieval_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 63.3% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_before.png|center|frame|rspec test coverage report before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After adding tests, the tests covered 91.1% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_after.png|center|frame|rspec test coverage report after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
We implemented factories in the rspec test file to improve modularity and code readability. Factories provide more flexibility in generating models to meet the requirements of the test, as opposed to fixtures. As you can see from the below images, the code is significantly cleaner as many lines of hardcoded strings have been removed. &lt;br /&gt;
[[File:prefactory.png|center|frame|rspec tests before factories were implemented]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:postfactory.png|center|frame|rspec tests after factories were implemented]]&lt;br /&gt;
&lt;br /&gt;
The below image shows the output of the following command after all tests were added: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:After refactor password retrieval controller.png|center|frame|rspec tests all passing after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/greyfiles/expertiza&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2460&lt;br /&gt;
* '''VCL Server:''' http://152.7.98.115:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Grey Files (unityid: mgfiles, github: greyfiles)&lt;br /&gt;
* Colin O'Dowd (unityid: cdodowd, github: colin-odowd)&lt;br /&gt;
* Pradyumna Khawas (unityid: ppkhawas, github: therealppk)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147414</id>
		<title>CSC/ECE 517/Spring 2023/E2308. Refactor course.rb and course team.rb models</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517/Spring_2023/E2308._Refactor_course.rb_and_course_team.rb_models&amp;diff=147414"/>
		<updated>2023-03-19T16:48:54Z</updated>

		<summary type="html">&lt;p&gt;Vspande: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Team Contact ==&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
* Kartik Rawool, (unityID:khrawool, GitHub:kartikrawool)&lt;br /&gt;
* Ameya Vaichalkar, (unityID:agvaicha, GitHub:ameyagv)&lt;br /&gt;
* Vikram Pande, (unityID:vspande, GitHub:vikrampande7)&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
* Kartiki Bhandakkar, kbhanda3&lt;br /&gt;
&lt;br /&gt;
== Overview of Expertiza ==&lt;br /&gt;
Expertiza is an open-source software written using Ruby on Rails which functions as a learning management software system. It has many different functions and abilities including the ability to create assignments, quizzes, assignment groups, and topics, and also a complete mechanism for providing peer reviews and feedback for other groups and other teammates. Part of its functionality is a system containing information about the course and its associated teams respectively. The &amp;lt;code&amp;gt;Course&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseTeam&amp;lt;/code&amp;gt; which are the models primarily addressed in this project are both critical components in providing this functionality.&lt;br /&gt;
&lt;br /&gt;
== Description of Project ==&lt;br /&gt;
&amp;lt;code&amp;gt;auth_controller&amp;lt;/code&amp;gt; is used for authentication purposes. The controller completes a variety of tasks including handling the correct user logins, incorrect passwords, unknown users, and making sure the session and role information is updated at all points in that process. The original problem description listed three issues, two of which had since been corrected by other code changes since the document was written. The remaining problem was that some logger messages were included in methods that could be placed more cleanly in &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; methods. Also, I personally noticed that there was a few lines of repeated code involved in resetting the role cache that needed to be combined into a shared private method.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;password_retrieval_controller&amp;lt;/code&amp;gt; deals with the process of updating and resetting a user password. The &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method generates a token and appends it to a password reset URL. If a user submits a valid email address on the &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view, the URL is sent to the user's email. When a user goes to the password reset URL, the token parameter is decrypted and checked for expiration. Next, the &amp;lt;code&amp;gt;password_retrieval/reset_password&amp;lt;/code&amp;gt; view is loaded where a user enters an updated password and is sent back to the home page. In this project, the method was refactored in the following ways: to adhere to DRY principles, removal of hardwired constants, renaming of methods and variables, and enhanced comments. In addition, RSpec testing coverage of the controller was improved from 63.33% to 91.8% through a series of new tests that validate the functionality of the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; methods.&lt;br /&gt;
&lt;br /&gt;
== Files Modified ==&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/password_retrieval_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated &amp;lt;code&amp;gt;check_reset_url&amp;lt;/code&amp;gt; method name to &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The method validates that the password reset token is valid and present. The updated method name provides a more functionally descriptive name. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|style=&amp;quot;width: 30%&amp;quot;| Replaced repeated code in lines 35-36 and 62-63&lt;br /&gt;
|The use of repeated code violates the DRY principle and so it was moved to a new method.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/5429abd6fcb39f7bdbb0aaa1813f19c8101d7e25 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Change token expiration time to constant in line 41&lt;br /&gt;
|This time should not be hardwired; it should be a constant or a parameter. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f0b51f6f2f106df8338483396a95d4068e39c7f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|Bugfix: Reload page if email is nil or empty on &amp;lt;code&amp;gt;password_retrieval/forgotten&amp;lt;/code&amp;gt; view&lt;br /&gt;
|An empty email parameter was causing the send password button to freeze. This was beyond the scope of our work but we wanted to improve the page functionality. &lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/70f77ac851b234f840709859dc1ee9d6725c34fc Commit]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|Improve overall comments and rewrite error messages&lt;br /&gt;
|The comments and error messages in the controller need to be more meaningful, specific and clear.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/1af745dc3b59641cb0266ebe49ee996718381fd0 Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; method&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;update_password&amp;lt;/code&amp;gt; method. We wanted to enhance the test suite of this controller by increasing the coverage of its Rspec tests.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/a90b1aada9878c7cdf7319dd022432cca8eadd2f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added two new RSpec tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method to check nil or blank input for email&lt;br /&gt;
|There were no tests for the &amp;lt;code&amp;gt;send_password&amp;lt;/code&amp;gt; method pertaining to checking invalid inputs in the request params&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/1d2d2d94ef730ab427bb326049bc5ec800a0dfc9 Commit]&amp;lt;br&amp;gt;[https://github.com/greyfiles/expertiza/commit/781d6f42ca37829e0e514de8bcef1c85b2a035a2 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; factories and removed hardcoded variables&lt;br /&gt;
|Cleaned up hardcoded &amp;lt;code&amp;gt;User&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;PasswordReset&amp;lt;/code&amp;gt; models with premade factories to improve readability of the code&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&amp;lt;br&amp;gt;[https://github.com/expertiza/expertiza/commit/96376e0b633e6b6e08d472a4cb4600d20e0c024f Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/factories/password_retrieval_factory.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Created a file to host the &amp;lt;code&amp;gt;password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt; fixtures&lt;br /&gt;
|We implemented factories in the rspec test file to improve modularity and code readability.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/e946533235846a853ee42908b15e75d628552f9e Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;config/routes.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Updated URL path and controller action to updated method name &amp;lt;code&amp;gt;check_token_validity&amp;lt;/code&amp;gt;&lt;br /&gt;
|The action and URL path must be renamed to generate pathing to the controller method and views.&lt;br /&gt;
|[https://github.com/expertiza/expertiza/commit/3f9f63ab51e90743dfab0b860574aa9b673f2717 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;app/controllers/auth_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Move logger messages to &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; blocks wherever possible&lt;br /&gt;
|Logger messages are inserted to log important events occurring in the code and do not relate directly to the logic. When possible, moving them to either &amp;lt;code&amp;gt;before_action&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;after_action&amp;lt;/code&amp;gt; blocks makes the code more readable and easier to understand. It also separates the functionality of the method itself and the logging functionality.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/7069f5d3cbfa2b7259e85e39dbfbf6fb41a0ce1d Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|*Not in required chagnes* Replaced repeated code for re-caching the user role&lt;br /&gt;
|We noticed that although not listed on the recommended changes, this action involved exactly repeated code in the controller. The use of repeated code violates the DRY principle and so it was moved to a new method called &amp;lt;code&amp;gt;self.rebuild_role_cache&amp;lt;/code&amp;gt;.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/9ef20cffa0fe7b8440b97856a6db4b5351eece35 Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Improved helper function names&lt;br /&gt;
|Originally we made the new helper functions used in logging have unhelpful, confusing names. Making them more clear helps the code to be more understandable.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/32f8435255add7b44b38fd747f81f435d331d14d Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Changes to &amp;lt;code&amp;gt;spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! Change !! Rationale !! Commit Link&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|Improved existing tests for &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; to explicitly test for a redirect&lt;br /&gt;
|When looking over the existing test cases, I noticed that the test that was verifying that the &amp;lt;code&amp;gt;after_login&amp;lt;/code&amp;gt; method would redirect the user only &amp;quot;allowed&amp;quot; the redirect and did not &amp;quot;expect&amp;quot; it. I changed it to &amp;quot;expect&amp;quot; the redirect to ensure that functionality is working.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; when the role is found to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;set_current_role&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the current role was set.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|Added a test for &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; to make sure it rebuilds the role cache&lt;br /&gt;
|In the unit tests for the &amp;lt;code&amp;gt;clear_user_info&amp;lt;/code&amp;gt; method, my new addition of a private helper method allowed us to ensure that the role cache was being rebuilt when the user's info was cleared.&lt;br /&gt;
|[https://github.com/greyfiles/expertiza/commit/23b3eaa888810f93a4af18c2ca6904ab21580a4b Commit]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
'''Everything in the testing segment was beyond the scope of our work. However, we wanted to validate our code through RSpec testing before merging into the &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; Expertiza branch. In the second submission phase, we plan to further enhance the testing suite of the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; through factories and fixtures.''' &lt;br /&gt;
&lt;br /&gt;
=== Test Plan - Manual/System Test Cases ===&lt;br /&gt;
Along with the unit tests that we have written to test our files, we conducted a few system tests manually to verify the functionality works as expected. The &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; is difficult for us to test because we don't have access to the email used to make the sample account, but the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; is very testable. Below is the tests we completed listed in the order of completion.&lt;br /&gt;
&lt;br /&gt;
==== 1) Test instructor login &amp;amp; redirect to home page ====&lt;br /&gt;
When navigating to the expertiza website, our branch correctly displayed the login page as shown below.&lt;br /&gt;
[[File:before_login.png|center|border|Form shown to the user before logging in to expertiza]]&lt;br /&gt;
After typing in the sample login credentials of &amp;quot;instructor6&amp;quot; and &amp;quot;password,&amp;quot; the user is then correctly logged in and redirected to the home page for instructors shown below.&lt;br /&gt;
[[File:after_login.png|center|border|1400px|Page shown to the user after logging in to expertiza]]&lt;br /&gt;
==== 2) Test instructor logout &amp;amp; redirect to login page ====&lt;br /&gt;
Then, when the user clicks the logout button, they are correctly logged out and redirected once again to the login page as shown below.&lt;br /&gt;
[[File:after_logout.png|center|border|Form shown to the user after logging out of expertiza]]&lt;br /&gt;
==== 3) Test incorrect login ====&lt;br /&gt;
When the user attempts to login but enters the incorrect login information of &amp;quot;instructor6&amp;quot; and &amp;quot;incorrect,&amp;quot; the user is shown the error message and then correctly redirected to the forgot password page shown below.&lt;br /&gt;
[[File:after_incorrect_login.png|center|border|1400px|Form shown to the user after an incorrect login attempt to expertiza]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;auth_controller_.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_auth_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After making all of the above changes to &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;, we ran the rspec tests for the controller again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_refactor_auth_controller.png|center|frame|rspec tests continuing to all pass after completing the refactoring]]&lt;br /&gt;
&lt;br /&gt;
We have successfully preserved the passing tests after the improvements we made to the &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. Next we looked at the existing tests to see if they could be improved. As listed in the files changed above, there were a few improvements to be made to &amp;lt;code&amp;gt;auth_controller_spec.rb&amp;lt;/code&amp;gt;. We improved a check for redirecting the user after logging in and added two tests to make sure the role cache was being rebuilt after both setting the current role and clearing the user info. We ran the tests again with the command: &amp;lt;code&amp;gt;rspec spec/controllers/auth_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:after_improving_auth_controller_spec.png|center|frame|rspec tests continuing to all pass after improving and adding to the auth_controller tests]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 91.94% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:coverage_before.png|center|frame|rspec test coverage report before the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
This is already a good coverage but after my changes I wanted to ensure my changes were also tested thoroughly. After adding tests, the tests covered 95.24% of &amp;lt;code&amp;gt;auth_controller.rb&amp;lt;/code&amp;gt;. It improved slightly to be an even better coverage.&lt;br /&gt;
[[File:coverage_after.png|center|frame|rspec test coverage report after the improvements to the auth_controller unit tests]]&lt;br /&gt;
&lt;br /&gt;
=== Automated Testing of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt; ===&lt;br /&gt;
Before any refactoring to &amp;lt;code&amp;gt;passsword_retrieval_controller.rb&amp;lt;/code&amp;gt; was done, we ran the rspec tests created for the controller with the following command: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:before_refactor_password_retrieval_controller.png|center|frame|rspec tests all passing before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
Tests prior to the changes covered 63.3% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_before.png|center|frame|rspec test coverage report before the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
After adding tests, the tests covered 91.1% of &amp;lt;code&amp;gt;password_retrieval_controller.rb&amp;lt;/code&amp;gt;.&lt;br /&gt;
[[File:E2252_password_retrieval_coverage_report_after.png|center|frame|rspec test coverage report after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
We implemented factories in the rspec test file to improve modularity and code readability. Factories provide more flexibility in generating models to meet the requirements of the test, as opposed to fixtures. As you can see from the below images, the code is significantly cleaner as many lines of hardcoded strings have been removed. &lt;br /&gt;
[[File:prefactory.png|center|frame|rspec tests before factories were implemented]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:postfactory.png|center|frame|rspec tests after factories were implemented]]&lt;br /&gt;
&lt;br /&gt;
The below image shows the output of the following command after all tests were added: &amp;lt;code&amp;gt;rspec spec/controllers/password_retrieval_controller_spec.rb&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:After refactor password retrieval controller.png|center|frame|rspec tests all passing after the refactoring was completed]]&lt;br /&gt;
&lt;br /&gt;
== Relevant Links ==&lt;br /&gt;
* '''Github Repository:''' https://github.com/greyfiles/expertiza&lt;br /&gt;
* '''Pull Request:''' https://github.com/expertiza/expertiza/pull/2460&lt;br /&gt;
* '''VCL Server:''' http://152.7.98.115:8080/&lt;br /&gt;
&lt;br /&gt;
== Contributors to this project ==&lt;br /&gt;
* Grey Files (unityid: mgfiles, github: greyfiles)&lt;br /&gt;
* Colin O'Dowd (unityid: cdodowd, github: colin-odowd)&lt;br /&gt;
* Pradyumna Khawas (unityid: ppkhawas, github: therealppk)&lt;/div&gt;</summary>
		<author><name>Vspande</name></author>
	</entry>
</feed>