<?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=Schawan</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=Schawan"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Schawan"/>
	<updated>2026-06-08T11:41:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=129205</id>
		<title>CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=129205"/>
		<updated>2019-11-12T04:18:15Z</updated>

		<summary type="html">&lt;p&gt;Schawan: /* Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Fix issues related to deadlines and late policies==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the issues and the approach towards solving them in the E1978. Fix issues related to deadlines and late policies project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===Problem Description===&lt;br /&gt;
----&lt;br /&gt;
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Issues with the Current Implementation====&lt;br /&gt;
----&lt;br /&gt;
The current implementation of Expertiza has the following Issues:&lt;br /&gt;
* '''Issue 1''' - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”. To avoid confusion, use “late policy” exclusively.&lt;br /&gt;
* '''Issue 2''' - Late policies cannot be created without raising an error.&lt;br /&gt;
* '''Issue 3''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.&lt;br /&gt;
* '''Issue 4''' - The &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater do not work. Expertiza has a way of adjusting due dates for a new assignment. If a new assignment is created by copying an old assignment, the due dates are copied too. It is likely that sometimes the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.) is wished. To avoid the need to edit all the deadlines manually, Expertiza has a date updater. However, it does not work.&lt;br /&gt;
* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Upload.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Scope===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - The scope of this issue is to change &amp;quot;penalty policy&amp;quot; to &amp;quot;late policy&amp;quot; on all the relevant UI screens (app/views/late_policies).&lt;br /&gt;
* '''Issue 2''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 3''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 4''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 5''' - The scope of this issue is to write test cases for late_policies_controller.rb and late_policy.rb.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Approach===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Imageedit_5_7549932958.jpg]]&lt;br /&gt;
&lt;br /&gt;
===Expected Results===&lt;br /&gt;
----&lt;br /&gt;
* '''Issue 1''' - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between &amp;quot;late policy&amp;quot; and &amp;quot;penalty policy&amp;quot;, as &amp;quot;late policy&amp;quot; will be used exclusively.&lt;br /&gt;
* '''Issue 2''' - Once this issue is fixed, late policies can be created without raising the &amp;quot;The following error occurred while saving the penalty policy:&amp;quot; error.&lt;br /&gt;
* '''Issue 3''' - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the Edit Assignment page.&lt;br /&gt;
* '''Issue 4''' - Once this issue is fixed, &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater will work and update the dates as it is supposed to.&lt;br /&gt;
* '''Issue 5''' - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Plan===&lt;br /&gt;
----&lt;br /&gt;
'''Automated Testing Using RSpec'''&lt;br /&gt;
&lt;br /&gt;
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to write tests for late_policy.rb and late_policies_controller.rb repesctively.&lt;br /&gt;
&lt;br /&gt;
'''Coverage'''&lt;br /&gt;
&lt;br /&gt;
To make sure we are covering all of our code (100%) with test cases we will use the Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually running the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Milestones===&lt;br /&gt;
----&lt;br /&gt;
'''11/01''' – Project Selection&lt;br /&gt;
&lt;br /&gt;
'''11/11''' – Create Design Doc&lt;br /&gt;
&lt;br /&gt;
'''11/15''' – setting up project environment and updating Design Doc &lt;br /&gt;
&lt;br /&gt;
'''11/25''' – Fix Issues 1,2 and 3 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''11/30''' – Fix issues 4 and 5 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''12/04''' – Update design doc and create &amp;amp; upload video&lt;br /&gt;
&lt;br /&gt;
'''12/06''' – Write tests for edge cases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Mentors===&lt;br /&gt;
----&lt;br /&gt;
*  Edward Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
*  Ramya Vijayakumar (rvijaya4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
----&lt;br /&gt;
* Rajit Bharambe (rbharam@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Saahil Chawande (schawan@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Natansh Negi (nnegi2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Hitarth Shah (hshah4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/rajitnb/expertiza GitHub Project Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=129202</id>
		<title>CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=129202"/>
		<updated>2019-11-12T04:18:02Z</updated>

		<summary type="html">&lt;p&gt;Schawan: /* Approach */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Fix issues related to deadlines and late policies==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the issues and the approach towards solving them in the E1978. Fix issues related to deadlines and late policies project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===Problem Description===&lt;br /&gt;
----&lt;br /&gt;
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Issues with the Current Implementation====&lt;br /&gt;
----&lt;br /&gt;
The current implementation of Expertiza has the following Issues:&lt;br /&gt;
* '''Issue 1''' - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”. To avoid confusion, use “late policy” exclusively.&lt;br /&gt;
* '''Issue 2''' - Late policies cannot be created without raising an error.&lt;br /&gt;
* '''Issue 3''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.&lt;br /&gt;
* '''Issue 4''' - The &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater do not work. Expertiza has a way of adjusting due dates for a new assignment. If a new assignment is created by copying an old assignment, the due dates are copied too. It is likely that sometimes the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.) is wished. To avoid the need to edit all the deadlines manually, Expertiza has a date updater. However, it does not work.&lt;br /&gt;
* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Upload.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Scope===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - The scope of this issue is to change &amp;quot;penalty policy&amp;quot; to &amp;quot;late policy&amp;quot; on all the relevant UI screens (app/views/late_policies).&lt;br /&gt;
* '''Issue 2''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 3''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 4''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 5''' - The scope of this issue is to write test cases for late_policies_controller.rb and late_policy.rb.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Approach===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Imageedit_5_7549932958.png]]&lt;br /&gt;
&lt;br /&gt;
===Expected Results===&lt;br /&gt;
----&lt;br /&gt;
* '''Issue 1''' - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between &amp;quot;late policy&amp;quot; and &amp;quot;penalty policy&amp;quot;, as &amp;quot;late policy&amp;quot; will be used exclusively.&lt;br /&gt;
* '''Issue 2''' - Once this issue is fixed, late policies can be created without raising the &amp;quot;The following error occurred while saving the penalty policy:&amp;quot; error.&lt;br /&gt;
* '''Issue 3''' - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the Edit Assignment page.&lt;br /&gt;
* '''Issue 4''' - Once this issue is fixed, &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater will work and update the dates as it is supposed to.&lt;br /&gt;
* '''Issue 5''' - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Plan===&lt;br /&gt;
----&lt;br /&gt;
'''Automated Testing Using RSpec'''&lt;br /&gt;
&lt;br /&gt;
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to write tests for late_policy.rb and late_policies_controller.rb repesctively.&lt;br /&gt;
&lt;br /&gt;
'''Coverage'''&lt;br /&gt;
&lt;br /&gt;
To make sure we are covering all of our code (100%) with test cases we will use the Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually running the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Milestones===&lt;br /&gt;
----&lt;br /&gt;
'''11/01''' – Project Selection&lt;br /&gt;
&lt;br /&gt;
'''11/11''' – Create Design Doc&lt;br /&gt;
&lt;br /&gt;
'''11/15''' – setting up project environment and updating Design Doc &lt;br /&gt;
&lt;br /&gt;
'''11/25''' – Fix Issues 1,2 and 3 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''11/30''' – Fix issues 4 and 5 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''12/04''' – Update design doc and create &amp;amp; upload video&lt;br /&gt;
&lt;br /&gt;
'''12/06''' – Write tests for edge cases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Mentors===&lt;br /&gt;
----&lt;br /&gt;
*  Edward Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
*  Ramya Vijayakumar (rvijaya4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
----&lt;br /&gt;
* Rajit Bharambe (rbharam@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Saahil Chawande (schawan@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Natansh Negi (nnegi2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Hitarth Shah (hshah4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/rajitnb/expertiza GitHub Project Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Imageedit_5_7549932958.jpg&amp;diff=129198</id>
		<title>File:Imageedit 5 7549932958.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Imageedit_5_7549932958.jpg&amp;diff=129198"/>
		<updated>2019-11-12T04:17:16Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128471</id>
		<title>CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128471"/>
		<updated>2019-11-11T03:06:38Z</updated>

		<summary type="html">&lt;p&gt;Schawan: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Fix issues related to deadlines and late policies==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the issues and the approach towards solving them in the E1978. Fix issues related to deadlines and late policies project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===Problem Description===&lt;br /&gt;
----&lt;br /&gt;
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Issues with the Current Implementation====&lt;br /&gt;
----&lt;br /&gt;
The current implementation of Expertiza has the following Issues:&lt;br /&gt;
* '''Issue 1''' - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”. To avoid confusion, use “late policy” exclusively.&lt;br /&gt;
* '''Issue 2''' - Late policies cannot be created without raising an error.&lt;br /&gt;
* '''Issue 3''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.&lt;br /&gt;
* '''Issue 4''' - The &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater do not work. Expertiza has a way of adjusting due dates for a new assignment. If a new assignment is created by copying an old assignment, the due dates are copied too. It is likely that sometimes the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.) is wished. To avoid the need to edit all the deadlines manually, Expertiza has a date updater. However, it does not work.&lt;br /&gt;
* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Upload.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Scope===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - The scope of this issue is to change &amp;quot;penalty policy&amp;quot; to &amp;quot;late policy&amp;quot; on all the relevant UI screens (app/views/late_policies).&lt;br /&gt;
* '''Issue 2''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 3''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 4''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 5''' - The scope of this issue is to write test cases for late_policies_controller.rb and late_policy.rb.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Approach===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expected Results===&lt;br /&gt;
----&lt;br /&gt;
* '''Issue 1''' - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between &amp;quot;late policy&amp;quot; and &amp;quot;penalty policy&amp;quot;, as &amp;quot;late policy&amp;quot; will be used exclusively.&lt;br /&gt;
* '''Issue 2''' - Once this issue is fixed, late policies can be created without raising the &amp;quot;The following error occurred while saving the penalty policy:&amp;quot; error.&lt;br /&gt;
* '''Issue 3''' - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the Edit Assignment page.&lt;br /&gt;
* '''Issue 4''' - Once this issue is fixed, &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater will work and update the dates as it is supposed to.&lt;br /&gt;
* '''Issue 5''' - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Test Plan===&lt;br /&gt;
----&lt;br /&gt;
'''Automated Testing Using RSpec'''&lt;br /&gt;
&lt;br /&gt;
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to write tests for late_policy.rb and late_policies_controller.rb repesctively.&lt;br /&gt;
&lt;br /&gt;
'''Coverage'''&lt;br /&gt;
&lt;br /&gt;
To make sure we are covering all of our code (100%) with test cases we will use the Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually running the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Milestones===&lt;br /&gt;
----&lt;br /&gt;
'''11/01''' – Project Selection&lt;br /&gt;
&lt;br /&gt;
'''11/11''' – Create Design Doc&lt;br /&gt;
&lt;br /&gt;
'''11/15''' – setting up project environment and updating Design Doc &lt;br /&gt;
&lt;br /&gt;
'''11/25''' – Fix Issues 1,2 and 3 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''11/30''' – Fix issues 4 and 5 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''12/04''' – Update design doc and create &amp;amp; upload video&lt;br /&gt;
&lt;br /&gt;
'''12/06''' – Write tests for edge cases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Mentors===&lt;br /&gt;
----&lt;br /&gt;
*  Edward Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
*  Ramya Vijayakumar (rvijaya4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
----&lt;br /&gt;
* Rajit Bharambe (rbharam@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Saahil Chawande (schawan@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Natansh Negi (nnegi2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Hitarth Shah (hshah4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/rajitnb/expertiza GitHub Project Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128470</id>
		<title>CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128470"/>
		<updated>2019-11-11T03:06:13Z</updated>

		<summary type="html">&lt;p&gt;Schawan: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Fix issues related to deadlines and late policies==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the issues and the approach towards solving them in the E1978. Fix issues related to deadlines and late policies project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===Problem Description===&lt;br /&gt;
----&lt;br /&gt;
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Issues with the Current Implementation====&lt;br /&gt;
----&lt;br /&gt;
The current implementation of Expertiza has the following Issues:&lt;br /&gt;
* '''Issue 1''' - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”. To avoid confusion, use “late policy” exclusively.&lt;br /&gt;
* '''Issue 2''' - Late policies cannot be created without raising an error.&lt;br /&gt;
* '''Issue 3''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.&lt;br /&gt;
* '''Issue 4''' - The &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater do not work. Expertiza has a way of adjusting due dates for a new assignment. If a new assignment is created by copying an old assignment, the due dates are copied too. It is likely that sometimes the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.) is wished. To avoid the need to edit all the deadlines manually, Expertiza has a date updater. However, it does not work.&lt;br /&gt;
* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Upload.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Scope===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - The scope of this issue is to change &amp;quot;penalty policy&amp;quot; to &amp;quot;late policy&amp;quot; on all the relevant UI screens (app/views/late_policies).&lt;br /&gt;
* '''Issue 2''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 3''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 4''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 5''' - The scope of this issue is to write test cases for late_policies_controller.rb and late_policy.rb.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Approach===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expected Results===&lt;br /&gt;
----&lt;br /&gt;
* '''Issue 1''' - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between &amp;quot;late policy&amp;quot; and &amp;quot;penalty policy&amp;quot;, as &amp;quot;late policy&amp;quot; will be used exclusively.&lt;br /&gt;
* '''Issue 2''' - Once this issue is fixed, late policies can be created without raising the &amp;quot;The following error occurred while saving the penalty policy:&amp;quot; error.&lt;br /&gt;
* '''Issue 3''' - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the Edit Assignment page.&lt;br /&gt;
* '''Issue 4''' - Once this issue is fixed, &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater will work and update the dates as it is supposed to.&lt;br /&gt;
* '''Issue 5''' - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Test Plan===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Automated Testing Using RSpec'''&lt;br /&gt;
&lt;br /&gt;
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to write tests for late_policy.rb and late_policies_controller.rb repesctively.&lt;br /&gt;
&lt;br /&gt;
'''Coverage'''&lt;br /&gt;
&lt;br /&gt;
To make sure we are covering all of our code (100%) with test cases we will use the Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually running the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Milestones===&lt;br /&gt;
----&lt;br /&gt;
'''11/01''' – Project Selection&lt;br /&gt;
&lt;br /&gt;
'''11/11''' – Create Design Doc&lt;br /&gt;
&lt;br /&gt;
'''11/15''' – setting up project environment and updating Design Doc &lt;br /&gt;
&lt;br /&gt;
'''11/25''' – Fix Issues 1,2 and 3 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''11/30''' – Fix issues 4 and 5 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''12/04''' – Update design doc and create &amp;amp; upload video&lt;br /&gt;
&lt;br /&gt;
'''12/06''' – Write tests for edge cases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Mentors===&lt;br /&gt;
----&lt;br /&gt;
*  Edward Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
*  Ramya Vijayakumar (rvijaya4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
----&lt;br /&gt;
* Rajit Bharambe (rbharam@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Saahil Chawande (schawan@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Natansh Negi (nnegi2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Hitarth Shah (hshah4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/rajitnb/expertiza GitHub Project Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128468</id>
		<title>CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128468"/>
		<updated>2019-11-11T03:05:50Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Fix issues related to deadlines and late policies==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the issues and the approach towards solving them in the E1978. Fix issues related to deadlines and late policies project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===Problem Description===&lt;br /&gt;
----&lt;br /&gt;
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Issues with the Current Implementation====&lt;br /&gt;
----&lt;br /&gt;
The current implementation of Expertiza has the following Issues:&lt;br /&gt;
* '''Issue 1''' - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”. To avoid confusion, use “late policy” exclusively.&lt;br /&gt;
* '''Issue 2''' - Late policies cannot be created without raising an error.&lt;br /&gt;
* '''Issue 3''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.&lt;br /&gt;
* '''Issue 4''' - The &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater do not work. Expertiza has a way of adjusting due dates for a new assignment. If a new assignment is created by copying an old assignment, the due dates are copied too. It is likely that sometimes the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.) is wished. To avoid the need to edit all the deadlines manually, Expertiza has a date updater. However, it does not work.&lt;br /&gt;
* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Upload.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Scope===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - The scope of this issue is to change &amp;quot;penalty policy&amp;quot; to &amp;quot;late policy&amp;quot; on all the relevant UI screens (app/views/late_policies).&lt;br /&gt;
* '''Issue 2''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 3''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 4''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 5''' - The scope of this issue is to write test cases for late_policies_controller.rb and late_policy.rb.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Approach===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Expected Results===&lt;br /&gt;
----&lt;br /&gt;
* '''Issue 1''' - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between &amp;quot;late policy&amp;quot; and &amp;quot;penalty policy&amp;quot;, as &amp;quot;late policy&amp;quot; will be used exclusively.&lt;br /&gt;
* '''Issue 2''' - Once this issue is fixed, late policies can be created without raising the &amp;quot;The following error occurred while saving the penalty policy:&amp;quot; error.&lt;br /&gt;
* '''Issue 3''' - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the Edit Assignment page.&lt;br /&gt;
* '''Issue 4''' - Once this issue is fixed, &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater will work and update the dates as it is supposed to.&lt;br /&gt;
* '''Issue 5''' - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Test Plan===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Automated Testing Using RSpec'''&lt;br /&gt;
&lt;br /&gt;
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to write tests for late_policy.rb and late_policies_controller.rb repesctively.&lt;br /&gt;
&lt;br /&gt;
'''Coverage'''&lt;br /&gt;
&lt;br /&gt;
To make sure we are covering all of our code (100%) with test cases we will use the Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually running the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Milestones===&lt;br /&gt;
----&lt;br /&gt;
'''11/01''' – Project Selection&lt;br /&gt;
&lt;br /&gt;
'''11/11''' – Create Design Doc&lt;br /&gt;
&lt;br /&gt;
'''11/15''' – setting up project environment and updating Design Doc &lt;br /&gt;
&lt;br /&gt;
'''11/25''' – Fix Issues 1,2 and 3 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''11/30''' – Fix issues 4 and 5 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''12/04''' – Update design doc and create &amp;amp; upload video&lt;br /&gt;
&lt;br /&gt;
'''12/06''' – Write tests for edge cases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Mentors===&lt;br /&gt;
----&lt;br /&gt;
*  Edward Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
*  Ramya Vijayakumar (rvijaya4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
----&lt;br /&gt;
* Rajit Bharambe (rbharam@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Saahil Chawande (schawan@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Natansh Negi (nnegi2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
* Hitarth Shah (hshah4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/rajitnb/expertiza GitHub Project Fork]&lt;br /&gt;
&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128464</id>
		<title>CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128464"/>
		<updated>2019-11-11T03:02:16Z</updated>

		<summary type="html">&lt;p&gt;Schawan: /* Project Mentors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Fix issues related to deadlines and late policies==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the issues and the approach towards solving them in the E1978. Fix issues related to deadlines and late policies project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===Problem Description===&lt;br /&gt;
----&lt;br /&gt;
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Issues with the Current Implementation====&lt;br /&gt;
----&lt;br /&gt;
The current implementation of Expertiza has the following Issues:&lt;br /&gt;
* '''Issue 1''' - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”. To avoid confusion, use “late policy” exclusively.&lt;br /&gt;
* '''Issue 2''' - Late policies cannot be created without raising an error.&lt;br /&gt;
* '''Issue 3''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.&lt;br /&gt;
* '''Issue 4''' - The &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater do not work. Expertiza has a way of adjusting due dates for a new assignment. If a new assignment is created by copying an old assignment, the due dates are copied too. It is likely that sometimes the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.) is wished. To avoid the need to edit all the deadlines manually, Expertiza has a date updater. However, it does not work.&lt;br /&gt;
* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Upload.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Scope===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - The scope of this issue is to change &amp;quot;penalty policy&amp;quot; to &amp;quot;late policy&amp;quot; on all the relevant UI screens (app/views/late_policies).&lt;br /&gt;
* '''Issue 2''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 3''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 4''' - The scope of this issue is to fix the function in ruby and write appropriate test cases (late_policies_controller.rb).&lt;br /&gt;
* '''Issue 5''' - The scope of this issue is to write test cases for late_policies_controller.rb and late_policy.rb.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between &amp;quot;late policy&amp;quot; and &amp;quot;penalty policy&amp;quot;, as &amp;quot;late policy&amp;quot; will be used exclusively.&lt;br /&gt;
* '''Issue 2''' - Once this issue is fixed, late policies can be created without raising the &amp;quot;The following error occurred while saving the penalty policy:&amp;quot; error.&lt;br /&gt;
* '''Issue 3''' - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the Edit Assignment page.&lt;br /&gt;
* '''Issue 4''' - Once this issue is fixed, &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater will work and update the dates as it is supposed to.&lt;br /&gt;
* '''Issue 5''' - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Approach===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Plan===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
'''Automated Testing Using RSpec'''&lt;br /&gt;
&lt;br /&gt;
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to write tests for late_policy.rb and late_policies_controller.rb repesctively.&lt;br /&gt;
&lt;br /&gt;
'''Coverage'''&lt;br /&gt;
&lt;br /&gt;
To make sure we are covering all of our code (100%) with test cases we will use the Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually running the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Milestones===&lt;br /&gt;
----&lt;br /&gt;
'''11/01''' – Project Selection&lt;br /&gt;
&lt;br /&gt;
'''11/11''' – Create Design Doc&lt;br /&gt;
&lt;br /&gt;
'''11/15''' – setting up project environment and updating Design Doc &lt;br /&gt;
&lt;br /&gt;
'''11/25''' – Fix Issues 1,2 and 3 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''11/30''' – Fix issues 4 and 5 with well-defined test cases&lt;br /&gt;
&lt;br /&gt;
'''12/04''' – Update design doc and create &amp;amp; upload video&lt;br /&gt;
&lt;br /&gt;
'''12/06''' – Write tests for edge cases.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Mentors===&lt;br /&gt;
----&lt;br /&gt;
*  Edward Gehringer (efg@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
*  Ramya Vijayakumar (rvijaya4@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
----&lt;br /&gt;
1. Rajit Bharambe (rbharam@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
2. Saahil Chawande (schawan@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
3. Natansh Negi (nnegi2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
4. Hitarth Shah (hshah4@ncsu.edu)&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128433</id>
		<title>CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128433"/>
		<updated>2019-11-11T02:23:38Z</updated>

		<summary type="html">&lt;p&gt;Schawan: /* Scope of the Project */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Fix issues related to deadlines and late policies==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the issues and the approach towards solving them in the E1978. Fix issues related to deadlines and late policies project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===Problem Description===&lt;br /&gt;
----&lt;br /&gt;
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Issues with the Current Implementation====&lt;br /&gt;
----&lt;br /&gt;
The current implementation of Expertiza has the following Issues:&lt;br /&gt;
* '''Issue 1''' - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”. To avoid confusion, use “late policy” exclusively.&lt;br /&gt;
* '''Issue 2''' - Late policies cannot be created without raising an error.&lt;br /&gt;
* '''Issue 3''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.&lt;br /&gt;
* '''Issue 4''' - The &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater do not work. Expertiza has a way of adjusting due dates for a new assignment. If a new assignment is created by copying an old assignment, the due dates are copied too. It is likely that sometimes the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.) is wished. To avoid the need to edit all the deadlines manually, Expertiza has a date updater. However, it does not work.&lt;br /&gt;
* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Scope of the Project===&lt;br /&gt;
----&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between &amp;quot;late policy&amp;quot; and &amp;quot;penalty policy&amp;quot;, as &amp;quot;late policy&amp;quot; will be used exclusively.&lt;br /&gt;
* '''Issue 2''' - Once this issue is fixed, late policies can be created without raising the &amp;quot;The following error occurred while saving the penalty policy:&amp;quot; error.&lt;br /&gt;
* '''Issue 3''' - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the Edit Assignment page.&lt;br /&gt;
* '''Issue 4''' - Once this issue is fixed, &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater will work and update the dates as it is supposed to.&lt;br /&gt;
* '''Issue 5''' - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Approach===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Plan===&lt;br /&gt;
----&lt;br /&gt;
'''Automated Testing Using Rspec'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to test late_policy.rb and late_policies_controller.rb repesctively.&lt;br /&gt;
&lt;br /&gt;
'''Coverage'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To make sure we are covering all of our code (100%) with test cases we will use Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually runnung the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Milestones===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128432</id>
		<title>CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128432"/>
		<updated>2019-11-11T02:23:21Z</updated>

		<summary type="html">&lt;p&gt;Schawan: /* Issues with the Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Fix issues related to deadlines and late policies==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the issues and the approach towards solving them in the E1978. Fix issues related to deadlines and late policies project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===Problem Description===&lt;br /&gt;
----&lt;br /&gt;
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Issues with the Current Implementation====&lt;br /&gt;
----&lt;br /&gt;
The current implementation of Expertiza has the following Issues:&lt;br /&gt;
* '''Issue 1''' - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”. To avoid confusion, use “late policy” exclusively.&lt;br /&gt;
* '''Issue 2''' - Late policies cannot be created without raising an error.&lt;br /&gt;
* '''Issue 3''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.&lt;br /&gt;
* '''Issue 4''' - The &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater do not work. Expertiza has a way of adjusting due dates for a new assignment. If a new assignment is created by copying an old assignment, the due dates are copied too. It is likely that sometimes the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.) is wished. To avoid the need to edit all the deadlines manually, Expertiza has a date updater. However, it does not work.&lt;br /&gt;
* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Scope of the Project===&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between &amp;quot;late policy&amp;quot; and &amp;quot;penalty policy&amp;quot;, as &amp;quot;late policy&amp;quot; will be used exclusively.&lt;br /&gt;
* '''Issue 2''' - Once this issue is fixed, late policies can be created without raising the &amp;quot;The following error occurred while saving the penalty policy:&amp;quot; error.&lt;br /&gt;
* '''Issue 3''' - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the Edit Assignment page.&lt;br /&gt;
* '''Issue 4''' - Once this issue is fixed, &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater will work and update the dates as it is supposed to.&lt;br /&gt;
* '''Issue 5''' - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Approach===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Plan===&lt;br /&gt;
----&lt;br /&gt;
'''Automated Testing Using Rspec'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to test late_policy.rb and late_policies_controller.rb repesctively.&lt;br /&gt;
&lt;br /&gt;
'''Coverage'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To make sure we are covering all of our code (100%) with test cases we will use Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually runnung the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Milestones===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128431</id>
		<title>CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128431"/>
		<updated>2019-11-11T02:23:03Z</updated>

		<summary type="html">&lt;p&gt;Schawan: /* Issues with the Current Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Fix issues related to deadlines and late policies==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the issues and the approach towards solving them in the E1978. Fix issues related to deadlines and late policies project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===Problem Description===&lt;br /&gt;
----&lt;br /&gt;
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Issues with the Current Implementation====&lt;br /&gt;
----&lt;br /&gt;
The current implementation of Expertiza has the following Issues:&lt;br /&gt;
* '''Issue 1''' - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”. To avoid confusion, use “late policy” exclusively.&lt;br /&gt;
* '''Issue 2''' - Late policies cannot be created without raising an error.&lt;br /&gt;
* '''Issue 3''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.&lt;br /&gt;
* '''Issue 4''' - The &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater do not work. Expertiza has a way of adjusting due dates for a new assignment. If a new assignment is created by copying an old assignment, the due dates are copied too. It is likely that sometimes the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.) is wished. To avoid the need to edit all the deadlines manually, Expertiza has a date updater. However, it does not work.&lt;br /&gt;
* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.&lt;br /&gt;
&lt;br /&gt;
===Scope of the Project===&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between &amp;quot;late policy&amp;quot; and &amp;quot;penalty policy&amp;quot;, as &amp;quot;late policy&amp;quot; will be used exclusively.&lt;br /&gt;
* '''Issue 2''' - Once this issue is fixed, late policies can be created without raising the &amp;quot;The following error occurred while saving the penalty policy:&amp;quot; error.&lt;br /&gt;
* '''Issue 3''' - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the Edit Assignment page.&lt;br /&gt;
* '''Issue 4''' - Once this issue is fixed, &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater will work and update the dates as it is supposed to.&lt;br /&gt;
* '''Issue 5''' - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Approach===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Plan===&lt;br /&gt;
----&lt;br /&gt;
'''Automated Testing Using Rspec'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to test late_policy.rb and late_policies_controller.rb repesctively.&lt;br /&gt;
&lt;br /&gt;
'''Coverage'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To make sure we are covering all of our code (100%) with test cases we will use Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually runnung the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Milestones===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128430</id>
		<title>CSC/ECE 517 Fall 2019 - E1978. Fix issues related to deadlines and late policies</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1978._Fix_issues_related_to_deadlines_and_late_policies&amp;diff=128430"/>
		<updated>2019-11-11T02:22:45Z</updated>

		<summary type="html">&lt;p&gt;Schawan: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Fix issues related to deadlines and late policies==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the issues and the approach towards solving them in the E1978. Fix issues related to deadlines and late policies project.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
===Problem Description===&lt;br /&gt;
----&lt;br /&gt;
Expertiza can automatically deduct points if a student is late in performing some action (e.g., submitting or reviewing). This is implemented by defining a new “late policy” and applying it to the assignment. Late policies are managed on the Due dates tab of assignment creation (or editing).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
====Issues with the Current Implementation====&lt;br /&gt;
The current implementation of Expertiza has the following Issues:&lt;br /&gt;
* '''Issue 1''' - In the UI, the policy is sometimes called a “late policy” and sometimes a “penalty policy”. To avoid confusion, use “late policy” exclusively.&lt;br /&gt;
* '''Issue 2''' - Late policies cannot be created without raising an error.&lt;br /&gt;
* '''Issue 3''' - After creating a late policy, the “back” link does not take the user back to editing the assignment.&lt;br /&gt;
* '''Issue 4''' - The &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater do not work. Expertiza has a way of adjusting due dates for a new assignment. If a new assignment is created by copying an old assignment, the due dates are copied too. It is likely that sometimes the same increment between due dates as in the old assignment (e.g., two days for the review phase, three days for resubmission, etc.) is wished. To avoid the need to edit all the deadlines manually, Expertiza has a date updater. However, it does not work.&lt;br /&gt;
* '''Issue 5''' - Neither late_policy.rb nor late_policies_controller.rb have any tests at all.&lt;br /&gt;
&lt;br /&gt;
===Scope of the Project===&lt;br /&gt;
Issues described in the above section all exist in the Due Dates tab on the Edit Assignment page.&lt;br /&gt;
* '''Issue 1''' - Once this issue is fixed, the Due Dates tab while editing an assignment will have no ambiguity between &amp;quot;late policy&amp;quot; and &amp;quot;penalty policy&amp;quot;, as &amp;quot;late policy&amp;quot; will be used exclusively.&lt;br /&gt;
* '''Issue 2''' - Once this issue is fixed, late policies can be created without raising the &amp;quot;The following error occurred while saving the penalty policy:&amp;quot; error.&lt;br /&gt;
* '''Issue 3''' - Once this issue is fixed, the back link after creating a late policy will rightly take the user to the Edit Assignment page.&lt;br /&gt;
* '''Issue 4''' - Once this issue is fixed, &amp;quot;+&amp;quot; and &amp;quot;-&amp;quot; buttons for Show/Hide Date Updater will work and update the dates as it is supposed to.&lt;br /&gt;
* '''Issue 5''' - The code coverage will definitely increase once tests for late_policy.rb and late_policies_controller.rb are written.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Approach===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test Plan===&lt;br /&gt;
----&lt;br /&gt;
'''Automated Testing Using Rspec'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
We plan to create two new files, late_policy_spec.rb and late_policies_controller_spec.rb to test late_policy.rb and late_policies_controller.rb repesctively.&lt;br /&gt;
&lt;br /&gt;
'''Coverage'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
To make sure we are covering all of our code (100%) with test cases we will use Ruby Code Coverage plugin of RubyMine and SimpleCov gem. After manually runnung the test file, the SimpleCov gem will highlight the lines of code which are being covered by our test cases in green color, and for those which are not being covered in red.&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Milestones===&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127493</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127493"/>
		<updated>2019-11-06T23:07:19Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png]]&lt;br /&gt;
----&lt;br /&gt;
[[File:Screenshoot_PR.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Results/Conclusions===&lt;br /&gt;
----&lt;br /&gt;
After refactoring the code, following is achieved:&lt;br /&gt;
#Made code more readable&lt;br /&gt;
#Cleaned up the code and made it tidier&lt;br /&gt;
#Removed redundant, unused code and comments&lt;br /&gt;
#Improved performance&lt;br /&gt;
#Made some things more generic (like get_status() method)&lt;br /&gt;
#Kept the code follow the DRY principle (delete_signup and delete_signup_as_instructor now satisfy the DRY principle)&lt;br /&gt;
#Combined and disposed &amp;quot;Like&amp;quot; or &amp;quot;Similar&amp;quot; code.&lt;br /&gt;
#Splitted out long functions into more manageable bite.&lt;br /&gt;
#Created reusable code&lt;br /&gt;
#Made the class and function cohesion better.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Mentors===&lt;br /&gt;
----&lt;br /&gt;
#Edward Gehringer (efg@ncsu.edu)&lt;br /&gt;
#Ramya Vijayakumar (rvijaya4@ncsu.edu)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
----&lt;br /&gt;
#Rajit Bharambe (rbharam@ncsu.edu)&lt;br /&gt;
#Saahil Chawande (schawan@ncsu.edu)&lt;br /&gt;
#Sravan Matta (skmatta@ncsu.edu)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127404</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127404"/>
		<updated>2019-11-06T21:23:46Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png]]&lt;br /&gt;
----&lt;br /&gt;
[[File:Screenshoot_PR.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Mentors===&lt;br /&gt;
----&lt;br /&gt;
#Edward Gehringer (efg@ncsu.edu)&lt;br /&gt;
#Ramya Vijayakumar (rvijaya4@ncsu.edu)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
----&lt;br /&gt;
#Rajit Bharambe (rbharam@ncsu.edu)&lt;br /&gt;
#Saahil Chawande (schawan@ncsu.edu)&lt;br /&gt;
#Sravan Matta (skmatta@ncsu.edu)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshoot_PR.png&amp;diff=127401</id>
		<title>File:Screenshoot PR.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshoot_PR.png&amp;diff=127401"/>
		<updated>2019-11-06T21:23:12Z</updated>

		<summary type="html">&lt;p&gt;Schawan: uploaded a new version of &amp;amp;quot;File:Screenshoot PR.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127400</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127400"/>
		<updated>2019-11-06T21:21:42Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png]]&lt;br /&gt;
[[File:Screenshoot_PR.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Mentors===&lt;br /&gt;
----&lt;br /&gt;
#Edward Gehringer (efg@ncsu.edu)&lt;br /&gt;
#Ramya Vijayakumar (rvijaya4@ncsu.edu)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
----&lt;br /&gt;
#Rajit Bharambe (rbharam@ncsu.edu)&lt;br /&gt;
#Saahil Chawande (schawan@ncsu.edu)&lt;br /&gt;
#Sravan Matta (skmatta@ncsu.edu)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshoot_PR.png&amp;diff=127398</id>
		<title>File:Screenshoot PR.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshoot_PR.png&amp;diff=127398"/>
		<updated>2019-11-06T21:20:59Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127396</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127396"/>
		<updated>2019-11-06T21:14:31Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Project Mentors===&lt;br /&gt;
----&lt;br /&gt;
#Edward Gehringer (efg@ncsu.edu)&lt;br /&gt;
#Ramya Vijayakumar (rvijaya4@ncsu.edu)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Team Members===&lt;br /&gt;
----&lt;br /&gt;
#Rajit Bharambe (rbharam@ncsu.edu)&lt;br /&gt;
#Saahil Chawande (schawan@ncsu.edu)&lt;br /&gt;
#Sravan Matta (skmatta@ncsu.edu)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshot.png&amp;diff=127379</id>
		<title>File:Screenshot.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshot.png&amp;diff=127379"/>
		<updated>2019-11-06T20:51:14Z</updated>

		<summary type="html">&lt;p&gt;Schawan: uploaded a new version of &amp;amp;quot;File:Screenshot.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The page we going to export to PDF&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshot.png&amp;diff=127376</id>
		<title>File:Screenshot.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshot.png&amp;diff=127376"/>
		<updated>2019-11-06T20:43:42Z</updated>

		<summary type="html">&lt;p&gt;Schawan: uploaded a new version of &amp;amp;quot;File:Screenshot.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The page we going to export to PDF&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127374</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127374"/>
		<updated>2019-11-06T20:41:49Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshot.png&amp;diff=127373</id>
		<title>File:Screenshot.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshot.png&amp;diff=127373"/>
		<updated>2019-11-06T20:41:25Z</updated>

		<summary type="html">&lt;p&gt;Schawan: uploaded a new version of &amp;amp;quot;File:Screenshot.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The page we going to export to PDF&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshot.png&amp;diff=127372</id>
		<title>File:Screenshot.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshot.png&amp;diff=127372"/>
		<updated>2019-11-06T20:40:16Z</updated>

		<summary type="html">&lt;p&gt;Schawan: uploaded a new version of &amp;amp;quot;File:Screenshot.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The page we going to export to PDF&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127370</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127370"/>
		<updated>2019-11-06T20:35:46Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png|200]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127369</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127369"/>
		<updated>2019-11-06T20:35:22Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png|200px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127368</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127368"/>
		<updated>2019-11-06T20:34:21Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png|Width100xHeight100]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127367</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127367"/>
		<updated>2019-11-06T20:34:01Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png|Width200xHeight200]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127366</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127366"/>
		<updated>2019-11-06T20:32:48Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127365</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127365"/>
		<updated>2019-11-06T20:32:27Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png|200px|left|alt text]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127364</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127364"/>
		<updated>2019-11-06T20:31:51Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png|200px|thumb|left|alt text]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127363</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127363"/>
		<updated>2019-11-06T20:30:06Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Screenshot.png]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshot.png&amp;diff=127362</id>
		<title>File:Screenshot.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Screenshot.png&amp;diff=127362"/>
		<updated>2019-11-06T20:29:10Z</updated>

		<summary type="html">&lt;p&gt;Schawan: uploaded a new version of &amp;amp;quot;File:Screenshot.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The page we going to export to PDF&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127359</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127359"/>
		<updated>2019-11-06T20:27:06Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127358</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127358"/>
		<updated>2019-11-06T20:26:38Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
'''Testing with Travis CI'''&lt;br /&gt;
[[File:Example.jpg]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127317</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127317"/>
		<updated>2019-11-06T18:37:05Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127316</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127316"/>
		<updated>2019-11-06T18:36:16Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
def get_status(status_for, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for already submitted work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;The student has already submitted their work, so you are not allowed to remove them.&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Drop failed for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;error&amp;quot;, :message =&amp;gt; &amp;quot;You cannot drop a student after the drop topic deadline!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], participant.user_id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped the student from the topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Student has been dropped from the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      if status_for == &amp;quot;student&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped your topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
      if status_for == &amp;quot;instructor&amp;quot;&lt;br /&gt;
        return {:type =&amp;gt; &amp;quot;success&amp;quot;, :message =&amp;gt; &amp;quot;You have successfully dropped the student from the topic!&amp;quot;}&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: assignment.id&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127315</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127315"/>
		<updated>2019-11-06T18:34:59Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127314</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127314"/>
		<updated>2019-11-06T18:31:56Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
   flash_message = get_status(&amp;quot;student&amp;quot;, participant, assignment, drop_topic_deadline)&lt;br /&gt;
    if flash_message[:type] == &amp;quot;error&amp;quot;&lt;br /&gt;
      flash[:error] = flash_message[:message]&lt;br /&gt;
    else&lt;br /&gt;
   end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127313</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127313"/>
		<updated>2019-11-06T18:30:36Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*The '''delete_signup''' method has repeated flash messages. These messages are moved to a new method to follow the DRY principle.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def delete_signup&lt;br /&gt;
    participant = AssignmentParticipant.find(params[:id])&lt;br /&gt;
    assignment = participant.assignment&lt;br /&gt;
    drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)&lt;br /&gt;
    # A student who has already submitted work should not be allowed to drop his/her topic!&lt;br /&gt;
    # (A student/team has submitted if participant directory_num is non-null or submitted_hyperlinks is non-null.)&lt;br /&gt;
    # If there is no drop topic deadline, student can drop topic at any time (if all the submissions are deleted)&lt;br /&gt;
    # If there is a drop topic deadline, student cannot drop topic after this deadline.&lt;br /&gt;
    if !participant.team.submitted_files.empty? or !participant.team.hyperlinks.empty?&lt;br /&gt;
      flash[:error] = &amp;quot;You have already submitted your work, so you are not allowed to drop your topic.&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for already submitted a work: ' + params[:topic_id].to_s)&lt;br /&gt;
    elsif !drop_topic_deadline.nil? and Time.now &amp;gt; drop_topic_deadline.due_at&lt;br /&gt;
      flash[:error] = &amp;quot;You cannot drop your topic after the drop topic deadline!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].id, 'Dropping topic for ended work: ' + params[:topic_id].to_s)&lt;br /&gt;
    else&lt;br /&gt;
      delete_signup_for_topic(assignment.id, params[:topic_id], session[:user].id)&lt;br /&gt;
      flash[:success] = &amp;quot;You have successfully dropped your topic!&amp;quot;&lt;br /&gt;
      ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].id, 'Student has dropped the topic: ' + params[:topic_id].to_s)&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to action: 'list', id: params[:id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
    if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127312</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127312"/>
		<updated>2019-11-06T18:20:29Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Fixed the if-else ladder in '''signup_as_instructor_action''' action:&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
      if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        if SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
          flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
        else&lt;br /&gt;
          flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
          ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
        end&lt;br /&gt;
     else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 def signup_as_instructor_action&lt;br /&gt;
    user = User.find_by(name: params[:username])&lt;br /&gt;
    if user.nil? # validate invalid user&lt;br /&gt;
      flash[:error] = &amp;quot;That student does not exist!&amp;quot;&lt;br /&gt;
    else&lt;br /&gt;
     if AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id] and SignUpSheet.signup_team(params[:assignment_id], user.id, params[:topic_id])&lt;br /&gt;
        flash[:success] = &amp;quot;You have successfully signed up the student for the topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor signed up student for topic: ' + params[:topic_id].to_s)&lt;br /&gt;
      elsif AssignmentParticipant.exists? user_id: user.id, parent_id: params[:assignment_id]&lt;br /&gt;
        flash[:error] = &amp;quot;The student has already signed up for a topic!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'Instructor is signing up a student who already has a topic')&lt;br /&gt;
      else&lt;br /&gt;
        flash[:error] = &amp;quot;The student is not registered for the assignment!&amp;quot;&lt;br /&gt;
        ExpertizaLogger.info LoggerMessage.new(controller_name, '', 'The student is not registered for the assignment: ' &amp;lt;&amp;lt; user.id)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to controller: 'assignments', action: 'edit', id: params[:assignment_id]&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127309</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127309"/>
		<updated>2019-11-06T17:48:56Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The '''update''' method has a lot of instance variables initialized. The method has been changed in the following ways&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
      @topic.topic_identifier = params[:topic][:topic_identifier]&lt;br /&gt;
      update_max_choosers @topic&lt;br /&gt;
      @topic.category = params[:topic][:category]&lt;br /&gt;
      @topic.topic_name = params[:topic][:topic_name]&lt;br /&gt;
      @topic.micropayment = params[:topic][:micropayment]&lt;br /&gt;
      @topic.description = params[:topic][:description]&lt;br /&gt;
      @topic.link = params[:topic][:link]&lt;br /&gt;
      @topic.save&lt;br /&gt;
      undo_link(&amp;quot;The topic: &amp;quot;#{@topic.topic_name}&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def update&lt;br /&gt;
    @topic = SignUpTopic.find(params[:id])&lt;br /&gt;
    if @topic&lt;br /&gt;
    update_max_choosers @topic&lt;br /&gt;
      updated_max_choosers = @topic.max_choosers&lt;br /&gt;
      @topic.update_attributes(topic_identifier: params[:topic][:topic_identifier], max_choosers: updated_max_choosers, category: params[:topic][:category], topic_name: params[:topic][:topic_name], micropayment: params[:topic][:micropayment], description: params[:topic][:description], link: params[:topic][:link])&lt;br /&gt;
      undo_link(&amp;quot;The topic: \&amp;quot;#{@topic.topic_name}\&amp;quot; has been successfully updated. &amp;quot;)&lt;br /&gt;
    else&lt;br /&gt;
      flash[:error] = &amp;quot;The topic could not be updated.&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127306</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127306"/>
		<updated>2019-11-06T17:23:26Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
* The '''create''' method was responsible for calling the update method directly. Generally the create method should not directly call the update method.&lt;br /&gt;
'''Before'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
'''After'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    topic = SignUpTopic.where(topic_name: params[:topic][:topic_name], assignment_id: params[:id]).first&lt;br /&gt;
    call_create_or_update(topic)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
# This method appropriately calls the create topic or update existing topic method&lt;br /&gt;
  def call_create_or_update(topic)&lt;br /&gt;
    if topic.nil?&lt;br /&gt;
      setup_new_topic&lt;br /&gt;
    else&lt;br /&gt;
      update_existing_topic topic&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127305</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127305"/>
		<updated>2019-11-06T17:19:22Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127304</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127304"/>
		<updated>2019-11-06T17:19:03Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Code Improvements===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127303</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127303"/>
		<updated>2019-11-06T17:18:06Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
----&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127302</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127302"/>
		<updated>2019-11-06T17:16:53Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;br /&gt;
&lt;br /&gt;
===References===&lt;br /&gt;
&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
#[https://github.com/saahilchawande/expertiza GitHub Project Repository Fork]&lt;br /&gt;
#[http://expertiza.ncsu.edu/ The live Expertiza website]&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
#[https://relishapp.com/rspec Rspec Documentation]&lt;br /&gt;
#Clean Code: A handbook of agile software craftsmanship. Author: Robert C Martin&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127301</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127301"/>
		<updated>2019-11-06T17:15:18Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 2''' - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
**'''Solution'''-Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 3''' - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
**'''Solution'''-Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 4''' - Destroy has a misleading else flash message.&lt;br /&gt;
**'''Solution'''-Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 5''' - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
***'''Solution'''-It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 6''' - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
**'''Solution'''-Several method names were appropriately improved and renamed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 7''' - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
**'''Solution'''-It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 8''' - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
**'''Solution'''-Provided comments for blocks of code and created helper methods.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 9''' - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
**'''Solution'''-Refactored the participants variable and improved readability.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 10''' - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
**'''Solution'''-The if-else ladder was made more elegant and readable.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* '''Issue 11''' - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
**'''Solution'''-The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127298</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127298"/>
		<updated>2019-11-06T17:07:28Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
----&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Issue 2 - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
* Issue 3 - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
* Issue 4 - Destroy has a misleading else flash message.&lt;br /&gt;
* Issue 5 - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
* Issue 6 - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
* Issue 7 - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
* Issue 8 - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
* Issue 9 - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
* Issue 10 - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
* Issue 11 - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
===Solutions===&lt;br /&gt;
----&lt;br /&gt;
We fixed the aforementioned issues in the file signup_sheet_controller.rb (sign_up_sheet_controller.rb before refactoring) by providing the following solutions:&lt;br /&gt;
 &lt;br /&gt;
* Issue 1 - &lt;br /&gt;
* Issue 2 - Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
* Issue 3 - Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
* Issue 4 - Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
* Issue 5 - It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
* Issue 6 - Several method names were appropriately improved and renamed.&lt;br /&gt;
* Issue 7 - It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
* Issue 8 - Provided comments for blocks of code and created helper methods.&lt;br /&gt;
* Issue 9 - Refactored the participants variable and improved readability.&lt;br /&gt;
* Issue 10 - The if-else ladder was made more elegant and readable.&lt;br /&gt;
* Issue 11 - The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127296</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127296"/>
		<updated>2019-11-06T17:06:59Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Issue 2 - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
* Issue 3 - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
* Issue 4 - Destroy has a misleading else flash message.&lt;br /&gt;
* Issue 5 - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
* Issue 6 - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
* Issue 7 - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
* Issue 8 - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
* Issue 9 - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
* Issue 10 - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
* Issue 11 - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
===Solutions===&lt;br /&gt;
----&lt;br /&gt;
We fixed the aforementioned issues in the file signup_sheet_controller.rb (sign_up_sheet_controller.rb before refactoring) by providing the following solutions:&lt;br /&gt;
 &lt;br /&gt;
* Issue 1 - &lt;br /&gt;
* Issue 2 - Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
* Issue 3 - Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
* Issue 4 - Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
* Issue 5 - It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
* Issue 6 - Several method names were appropriately improved and renamed.&lt;br /&gt;
* Issue 7 - It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
* Issue 8 - Provided comments for blocks of code and created helper methods.&lt;br /&gt;
* Issue 9 - Refactored the participants variable and improved readability.&lt;br /&gt;
* Issue 10 - The if-else ladder was made more elegant and readable.&lt;br /&gt;
* Issue 11 - The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127295</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127295"/>
		<updated>2019-11-06T17:06:47Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Issue 2 - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
* Issue 3 - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
* Issue 4 - Destroy has a misleading else flash message.&lt;br /&gt;
* Issue 5 - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
* Issue 6 - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
* Issue 7 - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
* Issue 8 - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
* Issue 9 - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
* Issue 10 - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
* Issue 11 - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
===Solutions===&lt;br /&gt;
----&lt;br /&gt;
We fixed the aforementioned issues in the file signup_sheet_controller.rb (sign_up_sheet_controller.rb before refactoring) by providing the following solutions:&lt;br /&gt;
 &lt;br /&gt;
* Issue 1 - &lt;br /&gt;
* Issue 2 - Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
* Issue 3 - Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
* Issue 4 - Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
* Issue 5 - It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
* Issue 6 - Several method names were appropriately improved and renamed.&lt;br /&gt;
* Issue 7 - It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
* Issue 8 - Provided comments for blocks of code and created helper methods.&lt;br /&gt;
* Issue 9 - Refactored the participants variable and improved readability.&lt;br /&gt;
* Issue 10 - The if-else ladder was made more elegant and readable.&lt;br /&gt;
* Issue 11 - The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127294</id>
		<title>CSC/ECE 517 Fall 2019 - Project E1943. Refactor sign up sheet controller.rb</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_Project_E1943._Refactor_sign_up_sheet_controller.rb&amp;diff=127294"/>
		<updated>2019-11-06T17:06:08Z</updated>

		<summary type="html">&lt;p&gt;Schawan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Refactor sign up sheet controller.rb==&lt;br /&gt;
&lt;br /&gt;
This page gives a description of the refactoring done in the sign_up_sheet_controller.rb as part of the OSS project.&lt;br /&gt;
&lt;br /&gt;
('''NOTE''': This wiki is not final and is still a work in progress.)&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===About Expertiza===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Description of the project===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
The following is an Expertiza based OSS project which deals with the signup_sheet_controller.rb. It focusses on refactoring some of the more complex methods, modifying some of the language to make it more Ruby friendly, removing some redundant code. The goal of this project is to attempt to make this part of the application easier to read and maintain.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Issues and Solutions===&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
* '''Issue 1''' - Inconsistent naming. When used as a verb, “sign up” is two words.  When an adjective or a noun, it should be one word, e.g., “signup_sheet_controller.” Cf.“sign_up_as_instructor”.&lt;br /&gt;
**'''Solution'''- Changed the name of the controller from sign_up_sheet_controller.rb --&amp;gt; signup_sheet_controller.rb. Also changed several method names that had 'sign_up' being used as an adjective or a noun to 'signup'.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
* Issue 2 - Create method has and if-else condition determining if create or update should be called. Create method should not be responsible for calling update.&lt;br /&gt;
* Issue 3 - Update method has a plethora of instance variables defined before updating. These might not be necessary. Decide whether so many instance variables are really needed.&lt;br /&gt;
* Issue 4 - Destroy has a misleading else flash message.&lt;br /&gt;
* Issue 5 - Add_signup_topics_staggered does not do anything. Find out why add_signup_topics_staggered simply calls add_signup_topics, and why separate functions are needed.&lt;br /&gt;
* Issue 6 - Several method names can be improved (including: load_add_signup_topics, list, ad_info etc.)&lt;br /&gt;
* Issue 7 - What are differences between signup_as_instructor and signup_as_instructor_action methods? Investigate if they are needed and improve the method names if both are needed.&lt;br /&gt;
* Issue 8 - The list method is too long and is sparsely commented. Provide comments and identify if the method can be split or made cleaner by moving code to models or helper methods.&lt;br /&gt;
* Issue 9 - Refactor participants variable in load_add_signup_topics&lt;br /&gt;
* Issue 10 - Signup_as_instructor_action has a complicated if-else ladder.&lt;br /&gt;
* Issue 11 - Delete_signup and delete_signup_as_instructor have much in common and violate the DRY principle.&lt;br /&gt;
&lt;br /&gt;
===About Signup Sheet Controller===&lt;br /&gt;
This controller is used while signing up for a topic from the signup sheet. This controller allows users to signup as an instructor as well as a student. An instructor has the authority to do CRUD operations on topics and enrolled/waitlisted members of each topic. The instructor can also add or update deadlines for the assignment. &lt;br /&gt;
&lt;br /&gt;
===Solutions===&lt;br /&gt;
----&lt;br /&gt;
We fixed the aforementioned issues in the file signup_sheet_controller.rb (sign_up_sheet_controller.rb before refactoring) by providing the following solutions:&lt;br /&gt;
 &lt;br /&gt;
* Issue 1 - &lt;br /&gt;
* Issue 2 - Created another method 'call_create_or_update' which has the if-else condition that determines if create or update is called.&lt;br /&gt;
* Issue 3 - Used a single update_attributes method in place of the many instance variables.&lt;br /&gt;
* Issue 4 - Changed the misleading flash message in the else condition to be more straightforward.&lt;br /&gt;
* Issue 5 - It was found that the method add_signup_topics_staggered was unnecessary and was removed.&lt;br /&gt;
* Issue 6 - Several method names were appropriately improved and renamed.&lt;br /&gt;
* Issue 7 - It was found that both the signup_as_instructor and signup_as_instructor_action methods are needed and their use was explained with proper comments.&lt;br /&gt;
* Issue 8 - Provided comments for blocks of code and created helper methods.&lt;br /&gt;
* Issue 9 - Refactored the participants variable and improved readability.&lt;br /&gt;
* Issue 10 - The if-else ladder was made more elegant and readable.&lt;br /&gt;
* Issue 11 - The excess code in both the delete_signup and delete_signup_as_instructor methods was removed and replaced by just one 'get_status' method call.&lt;/div&gt;</summary>
		<author><name>Schawan</name></author>
	</entry>
</feed>