<?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=Dbell5</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=Dbell5"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Dbell5"/>
	<updated>2026-05-09T10:56:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134437</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134437"/>
		<updated>2020-05-04T20:20:26Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Files to be modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed, and implemented for [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for CSC/ECE 517, Spring 2020.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://www.youtube.com/watch?v=F7nQsIUspQM&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
This feature was previously implemented and was detailed [http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics here]. The feature concluded with allowing 4 rubric scenarios for an assignment:&lt;br /&gt;
*Rubric does not vary by round or by topic.&lt;br /&gt;
*Rubric varies by round, but not by topic.&lt;br /&gt;
*Rubric varies by topic, but not by round.&lt;br /&gt;
*Rubric varies by both round and topic.&lt;br /&gt;
However, there were two issues with the implementation:&lt;br /&gt;
*Rubrics in the dropdown were only those created by the logged-in instructor, so the TA wouldn’t be able to see them&lt;br /&gt;
*Rubrics would not be saved after selecting them and saving.&lt;br /&gt;
In light of these issues, [https://github.com/gabalmat/expertiza/commit/23ed2cca2976f55515ea8980646e4432858bf446 changes] to expertiza were made as follows:&lt;br /&gt;
*Two additional columns are added into the Assignment table that determines whether Rubrics varies by either Round or Topic with default values False&lt;br /&gt;
*'''update_assignment_questionnaires''' method is re-implemented&lt;br /&gt;
**Having extra column in the assignment questionnaire table topic_id, no need for deleting all the data and re-writing it again every single time in the DB (this caused the previous implementation to have a delay when selecting **rubrics)&lt;br /&gt;
**The only varying value is questionnaire_id, the rest values may not change from Topics or Rubrics tabs, but can be added&lt;br /&gt;
*There are 4 (four) possible cases for saving and updating data:&lt;br /&gt;
**used_in_round = null and topic_id = null&lt;br /&gt;
**used_in_round = integer and topic_id = null&lt;br /&gt;
**used_in_round = null and topic_id = integer&lt;br /&gt;
**used_in_round = integer and topic_id = integer&lt;br /&gt;
This solved the issue of having rubrics save&lt;br /&gt;
===Problem===&lt;br /&gt;
The feature we have to implement was not fully committed due to the previously mentioned problems, so we have to reincorporate the missing code. However, a resulting issue is the inability for an instructor or TA to use rubrics that they did not create. The current problem can be broken down into the following parts:&lt;br /&gt;
# Integrate the changes made from the original implementation into the current version of Expertiza&lt;br /&gt;
# Allow an instructor/TA to chose rubrics that aren’t only theirs&lt;br /&gt;
# Create and update tests to reflect the changes as needed&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
Our proposed solution keeps the previous implementation, but changes rubric filtering to allow instructors/TAs to use filters that are not theirs. Alongside the changes in the original implementation we propose:&lt;br /&gt;
*Allow an instructor to choose different rubrics for different topics&lt;br /&gt;
**PROBLEM: The drop-downs for selecting rubrics show only those rubrics created by the currently-logged in instructor (per project mentor). &lt;br /&gt;
***SOLUTION: Change the filtering in the questionnaire_options method to reflect the desired filtering.&lt;br /&gt;
***FILE: app/helpers/assignment_helper.rb&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
Since our project is to improve upon a previous implementation that was slightly flawed, we will be modifying all of the same files that they previously modified (even if we don’t choose to alter their implementation in that file).&lt;br /&gt;
&lt;br /&gt;
The major modified files from the previous implementation include:&lt;br /&gt;
*'''Controllers'''&lt;br /&gt;
**''assignments_controller.rb'': To refresh the topics list when changing tabs&lt;br /&gt;
**''popup_controller.rb'': To add a potential error message to the rubric view scores popup&lt;br /&gt;
&lt;br /&gt;
*'''Models'''&lt;br /&gt;
**''assignment.rb'': Add methods to determine if an assignment varies by rubric/topic. (will be refactored as part of our change, however)&lt;br /&gt;
**''assignment_form.rb'': Add topic ids to created assignment questionnaires&lt;br /&gt;
**''assignment_questionnaire.rb'': Add topic id to assignment questionnaire model&lt;br /&gt;
**''review_response_map.rb'': To allow finding review questionnaires by topic id&lt;br /&gt;
**''sign_up_topic.rb'': To allow a topic to have many assignment questionnaires attach to it (via topic id)&lt;br /&gt;
&lt;br /&gt;
*'''Views'''&lt;br /&gt;
**''assignments/edit.html.erb'': To move topic editing view to its own file that is rendered as part of assignment edit&lt;br /&gt;
**''edit/_rubrics.html.erb'': Factor out common code into a function, update to use topic id&lt;br /&gt;
**''edit/_topics.html.erb'': Topic editing view that was moved from assignment edit view&lt;br /&gt;
**''popup/view_review_scores_popup.html.erb'': Assignments that vary by topic should not be displayed, instead getting error&lt;br /&gt;
**''sign_up_sheet/_table_line.html.erb'': Add questionnaires to signup sheet table if assignment varies by topic&lt;br /&gt;
&lt;br /&gt;
*'''Helpers'''&lt;br /&gt;
**''assignment_helper.rb'': To add a topic id to the searchable fields for a questionnaire&lt;br /&gt;
&lt;br /&gt;
*'''DB Migrate'''&lt;br /&gt;
**''XXXXXXXXXXX_add_topic_id_to_assignment_questionnaires.rb'': Migration to add topic id to assignment questionnaire schema&lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To address the issues brought up with the previous implementation, we will also make the following major modifications:&lt;br /&gt;
*'''Controllers'''&lt;br /&gt;
**''assignments_controller.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''grades_controller.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''popup_controller.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''Models'''&lt;br /&gt;
**''assignment.rb'': Add persisted fields to the assignment for varying by topic/round instead of using methods to determine it&lt;br /&gt;
**''assignment_form.rb'': No longer delete all existing questionnaires on update, update them instead. Now find questionnaire by assignment questionnaire and type rather than assignment/type/round_number/topic_id.&lt;br /&gt;
**''assignment_participant.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''feedback_response_map.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''on_the_fly_calc.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''self_review_response_map.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''tag_prompt_deployment.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''Views'''&lt;br /&gt;
**''edit/_rubrics.html.erb'': Modify to set assignment vary by round/topic fields instead of non persisted flags&lt;br /&gt;
&lt;br /&gt;
*'''Helpers'''&lt;br /&gt;
**''assignment_helper.rb'': Refactor by moving function to find questionnaire / assignment questionnaire to assignment_form.rb. Remove filters that only allow instructors to see rubrics.&lt;br /&gt;
**''grades_helper.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''summary_helper.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''DB Migrate'''&lt;br /&gt;
**''XXXXXXXXX_add_vary_by_topic_to_assignments.rb'': Migration to add “vary by topic” field to assignment&lt;br /&gt;
**''XXXXXXXXX_add_vary_by_round_to_assignments.rb'': Migration to add “vary by round” field to assignment &lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
We will be re-adding the database flow that was added in the previous implementation, linking ''sign_up_topic'' to ''assignment_questionnaire'' via a '''topic_id''' field.&lt;br /&gt;
[[File:HW04_table.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition to that, we will be adding two additional boolean fields to the ''assignment'' schema: '''vary_by_round''' and '''vary_by_topic'''. As discussed earlier, in the previous implementation, these were methods that were called to determine if an assignment varied by round/topic rather than a persisted value. &lt;br /&gt;
&lt;br /&gt;
[[File:E2026DatabaseFlow.png]]&lt;br /&gt;
&lt;br /&gt;
Only a subset of the fields for each table is shown in the diagram because most of the fields are not relevant to these changes and would only serve to distract from the relevant changes. Additions are shown in bold.&lt;br /&gt;
&lt;br /&gt;
==New Implementation==&lt;br /&gt;
While trying to integrate the previous team's implementation of this feature, we discovered that their method for querying AssignmentQuestionnaires (AQs) was flawed.&lt;br /&gt;
&lt;br /&gt;
It would always query for the AQs by assignment id, current round number, and current topic id.&lt;br /&gt;
&lt;br /&gt;
However, if the assignment did not have reviews that vary by round or topic, these values would be nil on the AQ, and the previous query would fail.&lt;br /&gt;
&lt;br /&gt;
To fix this, we modified the ''assignment_questionnaire'' function in the AssignmentForm model to check the Assignment's ''vary_by_round'' and ''vary_by_topic'' flags, and then add the corresponding fields to the query. &lt;br /&gt;
&lt;br /&gt;
This means that:&lt;br /&gt;
* If an assignment does not vary by round or by topic, the query for AQs will be by assignment id only.&lt;br /&gt;
* If the assignment varies by round but not topic, the query for AQs will be by assignment id and round number.&lt;br /&gt;
&lt;br /&gt;
[[File:AQNewImpl.PNG]]&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*As part of previous implementation, the team had introduced the following new RSpec test files. We have retained those file.&lt;br /&gt;
**spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
**spec/models/self_review_response_map_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
===Manual Testing in Expertiza UI===&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
All rspec tests part of [https://travis-ci.org/github/expertiza/expertiza/builds/679301186 Travis CI build] has passed. The [https://coveralls.io/jobs/61850924 code coverage] has increased by 10.9% to 41.425%.&lt;br /&gt;
&lt;br /&gt;
== Future Work==&lt;br /&gt;
After merging the previous team's work with expertiza, several RSpec tests failed.&lt;br /&gt;
*This was due to how questionnaires were retrieved/found for an assignment. Staggered deadlines also rely on finding questionnaires using topic id, which isn't handled until after an assignment is made.&lt;br /&gt;
*'''Resolved'''&lt;br /&gt;
However, undoing filtering results in even more errors across models, controllers, and forms. This feature, however is a quality of life improvement and is less of a priority.&lt;br /&gt;
* '''Unresolved'''&lt;br /&gt;
Another quality of life improvement is that staggered deadlines and topics cannot be added to an assignment until after the assignment has been created and saved.&lt;br /&gt;
* This issue exists on expertiza's beta branch itself, separate from our changes.&lt;br /&gt;
*'''Unresolved'''&lt;br /&gt;
&lt;br /&gt;
==Useful Links==&lt;br /&gt;
*'''Github''': https://github.com/abhishekupadhyaya/expertiza&lt;br /&gt;
*'''Pull Request''': https://github.com/expertiza/expertiza/pull/1720&lt;br /&gt;
*'''Demo Recording''': https://www.youtube.com/watch?v=3Ns3DYGtJdQ&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134436</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134436"/>
		<updated>2020-05-04T20:16:11Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Files to be modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed, and implemented for [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for CSC/ECE 517, Spring 2020.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://www.youtube.com/watch?v=F7nQsIUspQM&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
This feature was previously implemented and was detailed [http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics here]. The feature concluded with allowing 4 rubric scenarios for an assignment:&lt;br /&gt;
*Rubric does not vary by round or by topic.&lt;br /&gt;
*Rubric varies by round, but not by topic.&lt;br /&gt;
*Rubric varies by topic, but not by round.&lt;br /&gt;
*Rubric varies by both round and topic.&lt;br /&gt;
However, there were two issues with the implementation:&lt;br /&gt;
*Rubrics in the dropdown were only those created by the logged-in instructor, so the TA wouldn’t be able to see them&lt;br /&gt;
*Rubrics would not be saved after selecting them and saving.&lt;br /&gt;
In light of these issues, [https://github.com/gabalmat/expertiza/commit/23ed2cca2976f55515ea8980646e4432858bf446 changes] to expertiza were made as follows:&lt;br /&gt;
*Two additional columns are added into the Assignment table that determines whether Rubrics varies by either Round or Topic with default values False&lt;br /&gt;
*'''update_assignment_questionnaires''' method is re-implemented&lt;br /&gt;
**Having extra column in the assignment questionnaire table topic_id, no need for deleting all the data and re-writing it again every single time in the DB (this caused the previous implementation to have a delay when selecting **rubrics)&lt;br /&gt;
**The only varying value is questionnaire_id, the rest values may not change from Topics or Rubrics tabs, but can be added&lt;br /&gt;
*There are 4 (four) possible cases for saving and updating data:&lt;br /&gt;
**used_in_round = null and topic_id = null&lt;br /&gt;
**used_in_round = integer and topic_id = null&lt;br /&gt;
**used_in_round = null and topic_id = integer&lt;br /&gt;
**used_in_round = integer and topic_id = integer&lt;br /&gt;
This solved the issue of having rubrics save&lt;br /&gt;
===Problem===&lt;br /&gt;
The feature we have to implement was not fully committed due to the previously mentioned problems, so we have to reincorporate the missing code. However, a resulting issue is the inability for an instructor or TA to use rubrics that they did not create. The current problem can be broken down into the following parts:&lt;br /&gt;
# Integrate the changes made from the original implementation into the current version of Expertiza&lt;br /&gt;
# Allow an instructor/TA to chose rubrics that aren’t only theirs&lt;br /&gt;
# Create and update tests to reflect the changes as needed&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
Our proposed solution keeps the previous implementation, but changes rubric filtering to allow instructors/TAs to use filters that are not theirs. Alongside the changes in the original implementation we propose:&lt;br /&gt;
*Allow an instructor to choose different rubrics for different topics&lt;br /&gt;
**PROBLEM: The drop-downs for selecting rubrics show only those rubrics created by the currently-logged in instructor (per project mentor). &lt;br /&gt;
***SOLUTION: Change the filtering in the questionnaire_options method to reflect the desired filtering.&lt;br /&gt;
***FILE: app/helpers/assignment_helper.rb&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
Since our project is to improve upon a previous implementation that was slightly flawed, we will be modifying all of the same files that they previously modified (even if we don’t choose to alter their implementation in that file).&lt;br /&gt;
&lt;br /&gt;
The major modified files from the previous implementation include:&lt;br /&gt;
*'''Controllers'''&lt;br /&gt;
**''assignments_controller.rb'': To refresh the topics list when changing tabs&lt;br /&gt;
**''popup_controller.rb'': To add a potential error message to the rubric view scores popup&lt;br /&gt;
&lt;br /&gt;
*'''Models'''&lt;br /&gt;
**''assignment.rb'': Add methods to determine if an assignment varies by rubric/topic. (will be refactored as part of our change, however)&lt;br /&gt;
**''assignment_form.rb'': Add topic ids to created assignment questionnaires&lt;br /&gt;
**''assignment_questionnaire.rb'': Add topic id to assignment questionnaire model&lt;br /&gt;
**''review_response_map.rb'': To allow finding review questionnaires by topic id&lt;br /&gt;
**''sign_up_topic.rb'': To allow a topic to have many assignment questionnaires attach to it (via topic id)&lt;br /&gt;
&lt;br /&gt;
*'''Views'''&lt;br /&gt;
**''edit.html.erb'': To move topic editing view to its own file that is rendered as part of assignment edit&lt;br /&gt;
**''_rubrics.html.erb'': Factor out common code into a function, update to use topic id&lt;br /&gt;
**''_topics.html.erb'': Topic editing view that was moved from assignment edit view&lt;br /&gt;
**''view_review_scores_popup.html.erb'': Assignments that vary by topic should not be displayed, instead getting error&lt;br /&gt;
**''_table_line.html.erb'': Add questionnaires to signup sheet table if assignment varies by topic&lt;br /&gt;
&lt;br /&gt;
*'''Helpers'''&lt;br /&gt;
**''assignment_helper.rb'': To add a topic id to the searchable fields for a questionnaire&lt;br /&gt;
&lt;br /&gt;
*'''DB Migrate'''&lt;br /&gt;
**''XXXXXXXXXXX_add_topic_id_to_assignment_questionnaires.rb'': Migration to add topic id to assignment questionnaire schema&lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To address the issues brought up with the previous implementation, we will also make the following major modifications:&lt;br /&gt;
*'''Controllers'''&lt;br /&gt;
**''assignments_controller.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''grades_controller.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''popup_controller.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''Models'''&lt;br /&gt;
**''assignment.rb'': Add persisted fields to the assignment for varying by topic/round instead of using methods to determine it&lt;br /&gt;
**''assignment_form.rb'': No longer delete all existing questionnaires on update, update them instead. Now find questionnaire by assignment questionnaire and type rather than assignment/type/round_number/topic_id.&lt;br /&gt;
**''assignment_participant.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''feedback_response_map.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''on_the_fly_calc.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''self_review_response_map.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''tag_prompt_deployment.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''Views'''&lt;br /&gt;
**''_rubrics.html.erb'': Modify to set assignment vary by round/topic fields instead of non persisted flags&lt;br /&gt;
&lt;br /&gt;
*'''Helpers'''&lt;br /&gt;
**''assignment_helper.rb'': Refactor by moving function to find questionnaire / assignment questionnaire to assignment_form.rb. Remove filters that only allow instructors to see rubrics.&lt;br /&gt;
**''grades_helper.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''summary_helper.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''DB Migrate'''&lt;br /&gt;
**''XXXXXXXXX_add_vary_by_topic_to_assignments.rb'': Migration to add “vary by topic” field to assignment&lt;br /&gt;
**''XXXXXXXXX_add_vary_by_round_to_assignments.rb'': Migration to add “vary by round” field to assignment &lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
We will be re-adding the database flow that was added in the previous implementation, linking ''sign_up_topic'' to ''assignment_questionnaire'' via a '''topic_id''' field.&lt;br /&gt;
[[File:HW04_table.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition to that, we will be adding two additional boolean fields to the ''assignment'' schema: '''vary_by_round''' and '''vary_by_topic'''. As discussed earlier, in the previous implementation, these were methods that were called to determine if an assignment varied by round/topic rather than a persisted value. &lt;br /&gt;
&lt;br /&gt;
[[File:E2026DatabaseFlow.png]]&lt;br /&gt;
&lt;br /&gt;
Only a subset of the fields for each table is shown in the diagram because most of the fields are not relevant to these changes and would only serve to distract from the relevant changes. Additions are shown in bold.&lt;br /&gt;
&lt;br /&gt;
==New Implementation==&lt;br /&gt;
While trying to integrate the previous team's implementation of this feature, we discovered that their method for querying AssignmentQuestionnaires (AQs) was flawed.&lt;br /&gt;
&lt;br /&gt;
It would always query for the AQs by assignment id, current round number, and current topic id.&lt;br /&gt;
&lt;br /&gt;
However, if the assignment did not have reviews that vary by round or topic, these values would be nil on the AQ, and the previous query would fail.&lt;br /&gt;
&lt;br /&gt;
To fix this, we modified the ''assignment_questionnaire'' function in the AssignmentForm model to check the Assignment's ''vary_by_round'' and ''vary_by_topic'' flags, and then add the corresponding fields to the query. &lt;br /&gt;
&lt;br /&gt;
This means that:&lt;br /&gt;
* If an assignment does not vary by round or by topic, the query for AQs will be by assignment id only.&lt;br /&gt;
* If the assignment varies by round but not topic, the query for AQs will be by assignment id and round number.&lt;br /&gt;
&lt;br /&gt;
[[File:AQNewImpl.PNG]]&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*As part of previous implementation, the team had introduced the following new RSpec test files. We have retained those file.&lt;br /&gt;
**spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
**spec/models/self_review_response_map_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
===Manual Testing in Expertiza UI===&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
All rspec tests part of [https://travis-ci.org/github/expertiza/expertiza/builds/679301186 Travis CI build] has passed. The [https://coveralls.io/jobs/61850924 code coverage] has increased by 10.9% to 41.425%.&lt;br /&gt;
&lt;br /&gt;
== Future Work==&lt;br /&gt;
After merging the previous team's work with expertiza, several RSpec tests failed.&lt;br /&gt;
*This was due to how questionnaires were retrieved/found for an assignment. Staggered deadlines also rely on finding questionnaires using topic id, which isn't handled until after an assignment is made.&lt;br /&gt;
*'''Resolved'''&lt;br /&gt;
However, undoing filtering results in even more errors across models, controllers, and forms. This feature, however is a quality of life improvement and is less of a priority.&lt;br /&gt;
* '''Unresolved'''&lt;br /&gt;
Another quality of life improvement is that staggered deadlines and topics cannot be added to an assignment until after the assignment has been created and saved.&lt;br /&gt;
* This issue exists on expertiza's beta branch itself, separate from our changes.&lt;br /&gt;
*'''Unresolved'''&lt;br /&gt;
&lt;br /&gt;
==Useful Links==&lt;br /&gt;
*'''Github''': https://github.com/abhishekupadhyaya/expertiza&lt;br /&gt;
*'''Pull Request''': https://github.com/expertiza/expertiza/pull/1720&lt;br /&gt;
*'''Demo Recording''': https://www.youtube.com/watch?v=3Ns3DYGtJdQ&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134435</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134435"/>
		<updated>2020-05-04T20:15:36Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Files to be modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed, and implemented for [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for CSC/ECE 517, Spring 2020.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://www.youtube.com/watch?v=F7nQsIUspQM&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
This feature was previously implemented and was detailed [http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics here]. The feature concluded with allowing 4 rubric scenarios for an assignment:&lt;br /&gt;
*Rubric does not vary by round or by topic.&lt;br /&gt;
*Rubric varies by round, but not by topic.&lt;br /&gt;
*Rubric varies by topic, but not by round.&lt;br /&gt;
*Rubric varies by both round and topic.&lt;br /&gt;
However, there were two issues with the implementation:&lt;br /&gt;
*Rubrics in the dropdown were only those created by the logged-in instructor, so the TA wouldn’t be able to see them&lt;br /&gt;
*Rubrics would not be saved after selecting them and saving.&lt;br /&gt;
In light of these issues, [https://github.com/gabalmat/expertiza/commit/23ed2cca2976f55515ea8980646e4432858bf446 changes] to expertiza were made as follows:&lt;br /&gt;
*Two additional columns are added into the Assignment table that determines whether Rubrics varies by either Round or Topic with default values False&lt;br /&gt;
*'''update_assignment_questionnaires''' method is re-implemented&lt;br /&gt;
**Having extra column in the assignment questionnaire table topic_id, no need for deleting all the data and re-writing it again every single time in the DB (this caused the previous implementation to have a delay when selecting **rubrics)&lt;br /&gt;
**The only varying value is questionnaire_id, the rest values may not change from Topics or Rubrics tabs, but can be added&lt;br /&gt;
*There are 4 (four) possible cases for saving and updating data:&lt;br /&gt;
**used_in_round = null and topic_id = null&lt;br /&gt;
**used_in_round = integer and topic_id = null&lt;br /&gt;
**used_in_round = null and topic_id = integer&lt;br /&gt;
**used_in_round = integer and topic_id = integer&lt;br /&gt;
This solved the issue of having rubrics save&lt;br /&gt;
===Problem===&lt;br /&gt;
The feature we have to implement was not fully committed due to the previously mentioned problems, so we have to reincorporate the missing code. However, a resulting issue is the inability for an instructor or TA to use rubrics that they did not create. The current problem can be broken down into the following parts:&lt;br /&gt;
# Integrate the changes made from the original implementation into the current version of Expertiza&lt;br /&gt;
# Allow an instructor/TA to chose rubrics that aren’t only theirs&lt;br /&gt;
# Create and update tests to reflect the changes as needed&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
Our proposed solution keeps the previous implementation, but changes rubric filtering to allow instructors/TAs to use filters that are not theirs. Alongside the changes in the original implementation we propose:&lt;br /&gt;
*Allow an instructor to choose different rubrics for different topics&lt;br /&gt;
**PROBLEM: The drop-downs for selecting rubrics show only those rubrics created by the currently-logged in instructor (per project mentor). &lt;br /&gt;
***SOLUTION: Change the filtering in the questionnaire_options method to reflect the desired filtering.&lt;br /&gt;
***FILE: app/helpers/assignment_helper.rb&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
Since our project is to improve upon a previous implementation that was slightly flawed, we will be modifying all of the same files that they previously modified (even if we don’t choose to alter their implementation in that file).&lt;br /&gt;
&lt;br /&gt;
The major modified files from the previous implementation include:&lt;br /&gt;
*'''Controllers'''&lt;br /&gt;
**''assignments_controller.rb'': To refresh the topics list when changing tabs&lt;br /&gt;
**''popup_controller.rb'': To add a potential error message to the rubric view scores popup&lt;br /&gt;
&lt;br /&gt;
*'''Models'''&lt;br /&gt;
**''assignment.rb'': Add methods to determine if an assignment varies by rubric/topic. (will be refactored as part of our change, however)&lt;br /&gt;
**''assignment_form.rb'': Add topic ids to created assignment questionnaires&lt;br /&gt;
**''assignment_questionnaire.rb'': Add topic id to assignment questionnaire model&lt;br /&gt;
**''review_response_map.rb'': To allow finding review questionnaires by topic id&lt;br /&gt;
**''sign_up_topic.rb'': To allow a topic to have many assignment questionnaires attach to it (via topic id)&lt;br /&gt;
&lt;br /&gt;
*'''Views'''&lt;br /&gt;
**''edit.html.erb'': To move topic editing view to its own file that is rendered as part of assignment edit&lt;br /&gt;
**''_rubrics.html.erb'': Factor out common code into a function, update to use topic id&lt;br /&gt;
**''_topics.html.erb'': Topic editing view that was moved from assignment edit view&lt;br /&gt;
**''view_review_scores_popup.html.erb'': Assignments that vary by topic should not be displayed, instead getting error&lt;br /&gt;
**''_table_line.html.erb'': Add questionnaires to signup sheet table if assignment varies by topic&lt;br /&gt;
&lt;br /&gt;
*'''Helpers'''&lt;br /&gt;
**''assignment_helper.rb'': To add a topic id to the searchable fields for a questionnaire&lt;br /&gt;
&lt;br /&gt;
*DB Migrate&lt;br /&gt;
**''XXXXXXXXXXX_add_topic_id_to_assignment_questionnaires.rb'': Migration to add topic id to assignment questionnaire schema&lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To address the issues brought up with the previous implementation, we will also make the following major modifications:&lt;br /&gt;
*'''Controllers'''&lt;br /&gt;
**''assignments_controller.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''grades_controller.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''popup_controller.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''Models'''&lt;br /&gt;
**''assignment.rb'': Add persisted fields to the assignment for varying by topic/round instead of using methods to determine it&lt;br /&gt;
**''assignment_form.rb'': No longer delete all existing questionnaires on update, update them instead. Now find questionnaire by assignment questionnaire and type rather than assignment/type/round_number/topic_id.&lt;br /&gt;
**''assignment_participant.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''feedback_response_map.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''on_the_fly_calc.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''self_review_response_map.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''tag_prompt_deployment.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''Views'''&lt;br /&gt;
**''_rubrics.html.erb'': Modify to set assignment vary by round/topic fields instead of non persisted flags&lt;br /&gt;
&lt;br /&gt;
*'''Helpers'''&lt;br /&gt;
**''assignment_helper.rb'': Refactor by moving function to find questionnaire / assignment questionnaire to assignment_form.rb. Remove filters that only allow instructors to see rubrics.&lt;br /&gt;
**''grades_helper.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**''summary_helper.rb'': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''DB Migrate'''&lt;br /&gt;
**''XXXXXXXXX_add_vary_by_topic_to_assignments.rb'': Migration to add “vary by topic” field to assignment&lt;br /&gt;
**''XXXXXXXXX_add_vary_by_round_to_assignments.rb'': Migration to add “vary by round” field to assignment &lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
We will be re-adding the database flow that was added in the previous implementation, linking ''sign_up_topic'' to ''assignment_questionnaire'' via a '''topic_id''' field.&lt;br /&gt;
[[File:HW04_table.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition to that, we will be adding two additional boolean fields to the ''assignment'' schema: '''vary_by_round''' and '''vary_by_topic'''. As discussed earlier, in the previous implementation, these were methods that were called to determine if an assignment varied by round/topic rather than a persisted value. &lt;br /&gt;
&lt;br /&gt;
[[File:E2026DatabaseFlow.png]]&lt;br /&gt;
&lt;br /&gt;
Only a subset of the fields for each table is shown in the diagram because most of the fields are not relevant to these changes and would only serve to distract from the relevant changes. Additions are shown in bold.&lt;br /&gt;
&lt;br /&gt;
==New Implementation==&lt;br /&gt;
While trying to integrate the previous team's implementation of this feature, we discovered that their method for querying AssignmentQuestionnaires (AQs) was flawed.&lt;br /&gt;
&lt;br /&gt;
It would always query for the AQs by assignment id, current round number, and current topic id.&lt;br /&gt;
&lt;br /&gt;
However, if the assignment did not have reviews that vary by round or topic, these values would be nil on the AQ, and the previous query would fail.&lt;br /&gt;
&lt;br /&gt;
To fix this, we modified the ''assignment_questionnaire'' function in the AssignmentForm model to check the Assignment's ''vary_by_round'' and ''vary_by_topic'' flags, and then add the corresponding fields to the query. &lt;br /&gt;
&lt;br /&gt;
This means that:&lt;br /&gt;
* If an assignment does not vary by round or by topic, the query for AQs will be by assignment id only.&lt;br /&gt;
* If the assignment varies by round but not topic, the query for AQs will be by assignment id and round number.&lt;br /&gt;
&lt;br /&gt;
[[File:AQNewImpl.PNG]]&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*As part of previous implementation, the team had introduced the following new RSpec test files. We have retained those file.&lt;br /&gt;
**spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
**spec/models/self_review_response_map_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
===Manual Testing in Expertiza UI===&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
All rspec tests part of [https://travis-ci.org/github/expertiza/expertiza/builds/679301186 Travis CI build] has passed. The [https://coveralls.io/jobs/61850924 code coverage] has increased by 10.9% to 41.425%.&lt;br /&gt;
&lt;br /&gt;
== Future Work==&lt;br /&gt;
After merging the previous team's work with expertiza, several RSpec tests failed.&lt;br /&gt;
*This was due to how questionnaires were retrieved/found for an assignment. Staggered deadlines also rely on finding questionnaires using topic id, which isn't handled until after an assignment is made.&lt;br /&gt;
*'''Resolved'''&lt;br /&gt;
However, undoing filtering results in even more errors across models, controllers, and forms. This feature, however is a quality of life improvement and is less of a priority.&lt;br /&gt;
* '''Unresolved'''&lt;br /&gt;
Another quality of life improvement is that staggered deadlines and topics cannot be added to an assignment until after the assignment has been created and saved.&lt;br /&gt;
* This issue exists on expertiza's beta branch itself, separate from our changes.&lt;br /&gt;
*'''Unresolved'''&lt;br /&gt;
&lt;br /&gt;
==Useful Links==&lt;br /&gt;
*'''Github''': https://github.com/abhishekupadhyaya/expertiza&lt;br /&gt;
*'''Pull Request''': https://github.com/expertiza/expertiza/pull/1720&lt;br /&gt;
*'''Demo Recording''': https://www.youtube.com/watch?v=3Ns3DYGtJdQ&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134432</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134432"/>
		<updated>2020-05-04T20:07:01Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Files to be modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed, and implemented for [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for CSC/ECE 517, Spring 2020.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://www.youtube.com/watch?v=F7nQsIUspQM&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
This feature was previously implemented and was detailed [http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics here]. The feature concluded with allowing 4 rubric scenarios for an assignment:&lt;br /&gt;
*Rubric does not vary by round or by topic.&lt;br /&gt;
*Rubric varies by round, but not by topic.&lt;br /&gt;
*Rubric varies by topic, but not by round.&lt;br /&gt;
*Rubric varies by both round and topic.&lt;br /&gt;
However, there were two issues with the implementation:&lt;br /&gt;
*Rubrics in the dropdown were only those created by the logged-in instructor, so the TA wouldn’t be able to see them&lt;br /&gt;
*Rubrics would not be saved after selecting them and saving.&lt;br /&gt;
In light of these issues, [https://github.com/gabalmat/expertiza/commit/23ed2cca2976f55515ea8980646e4432858bf446 changes] to expertiza were made as follows:&lt;br /&gt;
*Two additional columns are added into the Assignment table that determines whether Rubrics varies by either Round or Topic with default values False&lt;br /&gt;
*'''update_assignment_questionnaires''' method is re-implemented&lt;br /&gt;
**Having extra column in the assignment questionnaire table topic_id, no need for deleting all the data and re-writing it again every single time in the DB (this caused the previous implementation to have a delay when selecting **rubrics)&lt;br /&gt;
**The only varying value is questionnaire_id, the rest values may not change from Topics or Rubrics tabs, but can be added&lt;br /&gt;
*There are 4 (four) possible cases for saving and updating data:&lt;br /&gt;
**used_in_round = null and topic_id = null&lt;br /&gt;
**used_in_round = integer and topic_id = null&lt;br /&gt;
**used_in_round = null and topic_id = integer&lt;br /&gt;
**used_in_round = integer and topic_id = integer&lt;br /&gt;
This solved the issue of having rubrics save&lt;br /&gt;
===Problem===&lt;br /&gt;
The feature we have to implement was not fully committed due to the previously mentioned problems, so we have to reincorporate the missing code. However, a resulting issue is the inability for an instructor or TA to use rubrics that they did not create. The current problem can be broken down into the following parts:&lt;br /&gt;
# Integrate the changes made from the original implementation into the current version of Expertiza&lt;br /&gt;
# Allow an instructor/TA to chose rubrics that aren’t only theirs&lt;br /&gt;
# Create and update tests to reflect the changes as needed&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
Our proposed solution keeps the previous implementation, but changes rubric filtering to allow instructors/TAs to use filters that are not theirs. Alongside the changes in the original implementation we propose:&lt;br /&gt;
*Allow an instructor to choose different rubrics for different topics&lt;br /&gt;
**PROBLEM: The drop-downs for selecting rubrics show only those rubrics created by the currently-logged in instructor (per project mentor). &lt;br /&gt;
***SOLUTION: Change the filtering in the questionnaire_options method to reflect the desired filtering.&lt;br /&gt;
***FILE: app/helpers/assignment_helper.rb&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
Since our project is to improve upon a previous implementation that was slightly flawed, we will be modifying all of the same files that they previously modified (even if we don’t choose to alter their implementation in that file).&lt;br /&gt;
&lt;br /&gt;
The major modified files from the previous implementation include:&lt;br /&gt;
*'''Controllers'''&lt;br /&gt;
**assignments_controller.rb: To refresh the topics list when changing tabs&lt;br /&gt;
**popup_controller.rb: To add a potential error message to the rubric view scores popup&lt;br /&gt;
&lt;br /&gt;
*'''Models'''&lt;br /&gt;
**assignment.rb: Add methods to determine if an assignment varies by rubric/topic. (will be refactored as part of our change, however)&lt;br /&gt;
**assignment_form.rb: Add topic ids to created assignment questionnaires&lt;br /&gt;
**assignment_questionnaire.rb: Add topic id to assignment questionnaire model&lt;br /&gt;
**review_response_map.rb: To allow finding review questionnaires by topic id&lt;br /&gt;
**sign_up_topic.rb: To allow a topic to have many assignment questionnaires attach to it (via topic id)&lt;br /&gt;
&lt;br /&gt;
*'''Views'''&lt;br /&gt;
**edit.html.erb: To move topic editing view to its own file that is rendered as part of assignment edit&lt;br /&gt;
**_rubrics.html.erb: Factor out common code into a function, update to use topic id&lt;br /&gt;
**_topics.html.erb: Topic editing view that was moved from assignment edit view&lt;br /&gt;
**view_review_scores_popup.html.erb: Assignments that vary by topic should not be displayed, instead getting error&lt;br /&gt;
**_table_line.html.erb: Add questionnaires to signup sheet table if assignment varies by topic&lt;br /&gt;
&lt;br /&gt;
*'''Helpers'''&lt;br /&gt;
**assignment_helper.rb: To add a topic id to the searchable fields for a questionnaire&lt;br /&gt;
&lt;br /&gt;
*DB Migrate&lt;br /&gt;
**XXXXXXXXXXX_add_topic_id_to_assignment_questionnaires.rb: Migration to add topic id to assignment questionnaire schema&lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To address the issues brought up with the previous implementation, we will also make the following major modifications:&lt;br /&gt;
*Controllers&lt;br /&gt;
**'''app/controllers/assignments_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**'''app/controllers/grades_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**'''app/controllers/popup_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*Models&lt;br /&gt;
**'''app/models/assignment.rb''': Add persisted fields to the assignment for varying by topic/round instead of using methods to determine it&lt;br /&gt;
**'''app/models/assignment_form.rb''': No longer delete all existing questionnaires on update, update them instead. Now find questionnaire by assignment questionnaire and type rather than assignment/type/round_number/topic_id.&lt;br /&gt;
**'''app/models/assignment_participant.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**'''app/models/feedback_response_map.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**'''app/models/on_the_fly_calc.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**'''app/models/self_review_response_map.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**'''app/models/tag_prompt_deployment.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*Views&lt;br /&gt;
**'''app/views/assignments/edit/_rubrics.html.erb''': Modify to set assignment vary by round/topic fields instead of non persisted flags&lt;br /&gt;
&lt;br /&gt;
*Helpers&lt;br /&gt;
**'''app/helpers/assignment_helper.rb''': Refactor by moving function to find questionnaire / assignment questionnaire to assignment_form.rb. Remove filters that only allow instructors to see rubrics.&lt;br /&gt;
**'''app/helpers/grades_helper.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
**'''app/helpers/summary_helper.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*DB Migrate&lt;br /&gt;
**'''db/migrate/XXXXXXXXX_add_vary_by_topic_to_assignments.rb''': Migration to add “vary by topic” field to assignment&lt;br /&gt;
**'''db/migrate/XXXXXXXXX_add_vary_by_round_to_assignments.rb''': Migration to add “vary by round” field to assignment &lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
We will be re-adding the database flow that was added in the previous implementation, linking ''sign_up_topic'' to ''assignment_questionnaire'' via a '''topic_id''' field.&lt;br /&gt;
[[File:HW04_table.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition to that, we will be adding two additional boolean fields to the ''assignment'' schema: '''vary_by_round''' and '''vary_by_topic'''. As discussed earlier, in the previous implementation, these were methods that were called to determine if an assignment varied by round/topic rather than a persisted value. &lt;br /&gt;
&lt;br /&gt;
[[File:E2026DatabaseFlow.png]]&lt;br /&gt;
&lt;br /&gt;
Only a subset of the fields for each table is shown in the diagram because most of the fields are not relevant to these changes and would only serve to distract from the relevant changes. Additions are shown in bold.&lt;br /&gt;
&lt;br /&gt;
==New Implementation==&lt;br /&gt;
While trying to integrate the previous team's implementation of this feature, we discovered that their method for querying AssignmentQuestionnaires (AQs) was flawed.&lt;br /&gt;
&lt;br /&gt;
It would always query for the AQs by assignment id, current round number, and current topic id.&lt;br /&gt;
&lt;br /&gt;
However, if the assignment did not have reviews that vary by round or topic, these values would be nil on the AQ, and the previous query would fail.&lt;br /&gt;
&lt;br /&gt;
To fix this, we modified the ''assignment_questionnaire'' function in the AssignmentForm model to check the Assignment's ''vary_by_round'' and ''vary_by_topic'' flags, and then add the corresponding fields to the query. &lt;br /&gt;
&lt;br /&gt;
This means that:&lt;br /&gt;
* If an assignment does not vary by round or by topic, the query for AQs will be by assignment id only.&lt;br /&gt;
* If the assignment varies by round but not topic, the query for AQs will be by assignment id and round number.&lt;br /&gt;
&lt;br /&gt;
[[File:AQNewImpl.PNG]]&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we modified existing code as well as added new code. To ensure that existing functionality was not broken, and new functionality worked as expected, we used the following Test Strategy (which was also used by previous team):&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files have been modified and they pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*As part of previous implementation, the team had introduced the following new RSpec test files. We have retained those file.&lt;br /&gt;
**spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
**spec/models/self_review_response_map_spec.rb&lt;br /&gt;
*All these rspec tests passed.&lt;br /&gt;
&lt;br /&gt;
===Manual Testing in Expertiza UI===&lt;br /&gt;
Here we describe manual UI Testing steps to edit an existing assignment to allow it have to specialized rubrics for different topic types. These steps are also shown in recorded demo video.&lt;br /&gt;
*Login to Expertiza using instructor account (For testing, username: '''instructor6''', password: '''password''')&lt;br /&gt;
*Click on Manage &amp;gt; Assignments&lt;br /&gt;
*Click on Edit option for any assignment, you should get following view. Make sure '''Has topics?''' box is checked.&lt;br /&gt;
[[File:Assignment edit 3.png]]&lt;br /&gt;
*Click on Rubrics tab. You will see 2 checkboxes ('''Review rubric varies by round?''', '''Review rubric varies by topic?''')&lt;br /&gt;
*Check the box for '''Review rubric varies by topic?'''&lt;br /&gt;
*Go to Topics tab and verify that there is dropdown menu beside each Topic.&lt;br /&gt;
*Select a rubric from dropdown menu, and click '''Save'''&lt;br /&gt;
[[File:Topics rubric 2.png]]&lt;br /&gt;
*Go back to Home, and select the same assignment to edit. When you click on Topics tab, you should see the rubric you had selected.&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
All rspec tests part of [https://travis-ci.org/github/expertiza/expertiza/builds/679301186 Travis CI build] has passed. The [https://coveralls.io/jobs/61850924 code coverage] has increased by 10.9% to 41.425%.&lt;br /&gt;
&lt;br /&gt;
== Future Work==&lt;br /&gt;
After merging the previous team's work with expertiza, several RSpec tests failed.&lt;br /&gt;
*This was due to how questionnaires were retrieved/found for an assignment. Staggered deadlines also rely on finding questionnaires using topic id, which isn't handled until after an assignment is made.&lt;br /&gt;
*'''Resolved'''&lt;br /&gt;
However, undoing filtering results in even more errors across models, controllers, and forms. This feature, however is a quality of life improvement and is less of a priority.&lt;br /&gt;
* '''Unresolved'''&lt;br /&gt;
Another quality of life improvement is that staggered deadlines and topics cannot be added to an assignment until after the assignment has been created and saved.&lt;br /&gt;
* This issue exists on expertiza's beta branch itself, separate from our changes.&lt;br /&gt;
*'''Unresolved'''&lt;br /&gt;
&lt;br /&gt;
==Useful Links==&lt;br /&gt;
*'''Github''': https://github.com/abhishekupadhyaya/expertiza&lt;br /&gt;
*'''Pull Request''': https://github.com/expertiza/expertiza/pull/1720&lt;br /&gt;
*'''Demo Recording''': https://www.youtube.com/watch?v=3Ns3DYGtJdQ&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134295</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134295"/>
		<updated>2020-04-25T04:33:33Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: Undo revision 134293 by Dbell5 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed, and implemented for [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for CSC/ECE 517, Spring 2020.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://www.youtube.com/watch?v=F7nQsIUspQM&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
This feature was previously implemented and was detailed [http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics here]. The feature concluded with allowing 4 rubric scenarios for an assignment:&lt;br /&gt;
*Rubric does not vary by round or by topic.&lt;br /&gt;
*Rubric varies by round, but not by topic.&lt;br /&gt;
*Rubric varies by topic, but not by round.&lt;br /&gt;
*Rubric varies by both round and topic.&lt;br /&gt;
However, there were two issues with the implementation:&lt;br /&gt;
*Rubrics in the dropdown were only those created by the logged-in instructor, so the TA wouldn’t be able to see them&lt;br /&gt;
*Rubrics would not be saved after selecting them and saving.&lt;br /&gt;
In light of these issues, [https://github.com/gabalmat/expertiza/commit/23ed2cca2976f55515ea8980646e4432858bf446 changes] to expertiza were made as follows:&lt;br /&gt;
*Two additional columns are added into the Assignment table that determines whether Rubrics varies by either Round or Topic with default values False&lt;br /&gt;
*'''update_assignment_questionnaires''' method is re-implemented&lt;br /&gt;
**Having extra column in the assignment questionnaire table topic_id, no need for deleting all the data and re-writing it again every single time in the DB (this caused the previous implementation to have a delay when selecting **rubrics)&lt;br /&gt;
**The only varying value is questionnaire_id, the rest values may not change from Topics or Rubrics tabs, but can be added&lt;br /&gt;
*There are 4 (four) possible cases for saving and updating data:&lt;br /&gt;
**used_in_round = null and topic_id = null&lt;br /&gt;
**used_in_round = integer and topic_id = null&lt;br /&gt;
**used_in_round = null and topic_id = integer&lt;br /&gt;
**used_in_round = integer and topic_id = integer&lt;br /&gt;
This solved the issue of having rubrics save&lt;br /&gt;
===Problem===&lt;br /&gt;
The feature we have to implement was not fully committed due to the previously mentioned problems, so we have to reincorporate the missing code. However, a resulting issue is the inability for an instructor or TA to use rubrics that they did not create. The current problem can be broken down into the following parts:&lt;br /&gt;
# Integrate the changes made from the original implementation into the current version of Expertiza&lt;br /&gt;
# Allow an instructor/TA to chose rubrics that aren’t only theirs&lt;br /&gt;
# Create and update tests to reflect the changes as needed&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
Our proposed solution keeps the previous implementation, but changes rubric filtering to allow instructors/TAs to use filters that are not theirs. Alongside the changes in the original implementation we propose:&lt;br /&gt;
*Allow an instructor to choose different rubrics for different topics&lt;br /&gt;
**PROBLEM: The drop-downs for selecting rubrics show only those rubrics created by the currently-logged in instructor (per project mentor). &lt;br /&gt;
***SOLUTION: Change the filtering in the questionnaire_options method to reflect the desired filtering.&lt;br /&gt;
***FILE: app/helpers/assignment_helper.rb&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
Since our project is to improve upon a previous implementation that was slightly flawed, we will be modifying all of the same files that they previously modified (even if we don’t choose to alter their implementation in that file).&lt;br /&gt;
&lt;br /&gt;
The major modified files from the previous implementation include:&lt;br /&gt;
*'''app/controllers/assignments_controller.rb''': To refresh the topics list when changing tabs&lt;br /&gt;
*'''app/controllers/popup_controller.rb''': To add a potential error message to the rubric view scores popup&lt;br /&gt;
*'''app/helpers/assignment_helper.rb''': To add a topic id to the searchable fields for a questionnaire&lt;br /&gt;
*'''app/models/assignment.rb''': Add methods to determine if an assignment varies by rubric/topic. (will be refactored as part of our change, however)&lt;br /&gt;
*'''app/models/assignment_form.rb''': Add topic ids to created assignment questionnaires&lt;br /&gt;
*'''app/models/assignment_questionnaire.rb''': Add topic id to assignment questionnaire model&lt;br /&gt;
*'''app/models/review_response_map.rb''': To allow finding review questionnaires by topic id&lt;br /&gt;
*'''app/models/sign_up_topic.rb''': To allow a topic to have many assignment questionnaires attach to it (via topic id)&lt;br /&gt;
*'''app/views/assignments/edit.html.erb''': To move topic editing view to its own file that is rendered as part of assignment edit&lt;br /&gt;
*'''app/views/assignments/edit/_rubrics.html.erb''': Factor out common code into a function, update to use topic id&lt;br /&gt;
*'''app/views/assignments/edit/_topics.html.erb''': Topic editing view that was moved from assignment edit view&lt;br /&gt;
*'''app/views/popup/view_review_scores_popup.html.erb''': Assignments that vary by topic should not be displayed, instead getting error&lt;br /&gt;
*'''app/views/sign_up_sheet/_table_line.html.erb''': Add questionnaires to signup sheet table if assignment varies by topic&lt;br /&gt;
*'''db/migrate/XXXXXXXXXXX_add_topic_id_to_assignment_questionnaires.rb''': Migration to add topic id to assignment questionnaire schema&lt;br /&gt;
*'''...As well as many test files related to the above changes'''&lt;br /&gt;
&lt;br /&gt;
To address the issues brought up with the previous implementation, we will also make the following major modifications:&lt;br /&gt;
*'''app/models/assignment.rb''': Add persisted fields to the assignment for varying by topic/round instead of using methods to determine it&lt;br /&gt;
*'''app/helpers/assignment_helper.rb''': Refactor by moving function to find questionnaire / assignment questionnaire to assignment_form.rb. Remove filters that only allow instructors to see rubrics.&lt;br /&gt;
*'''app/models/assignment_form.rb''': No longer delete all existing questionnaires on update, update them instead. Now find questionnaire by assignment questionnaire and type rather than assignment/type/round_number/topic_id.&lt;br /&gt;
*'''app/views/assignments/edit/_rubrics.html.erb''': Modify to set assignment vary by round/topic fields instead of non persisted flags&lt;br /&gt;
*'''db/migrate/XXXXXXXXX_add_vary_by_topic_to_assignments.rb''': Migration to add “vary by topic” field to assignment&lt;br /&gt;
*'''db/migrate/XXXXXXXXX_add_vary_by_round_to_assignments.rb''': Migration to add “vary by round” field to assignment &lt;br /&gt;
*'''app/controllers/assignments_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/controllers/grades_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/controllers/popup_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/helpers/grades_helper.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/helpers/summary_helper.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/assignment_participant.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/feedback_response_map.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/on_the_fly_calc.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/self_review_response_map.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/tag_prompt_deployment.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
We will be re-adding the database flow that was added in the previous implementation, linking ''sign_up_topic'' to ''assignment_questionnaire'' via a '''topic_id''' field.&lt;br /&gt;
[[File:HW04_table.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition to that, we will be adding two additional boolean fields to the ''assignment'' schema: '''vary_by_round''' and '''vary_by_topic'''. As discussed earlier, in the previous implementation, these were methods that were called to determine if an assignment varied by round/topic rather than a persisted value. &lt;br /&gt;
&lt;br /&gt;
[[File:E2026DatabaseFlow.png]]&lt;br /&gt;
&lt;br /&gt;
Only a subset of the fields for each table is shown in the diagram because most of the fields are not relevant to these changes and would only serve to distract from the relevant changes. Additions are shown in bold.&lt;br /&gt;
&lt;br /&gt;
==New Implementation==&lt;br /&gt;
While trying to integrate the previous team's implementation of this feature, we discovered that their method for querying AssignmentQuestionnaires (AQs) was flawed.&lt;br /&gt;
&lt;br /&gt;
It would always query for the AQs by assignment id, current round number, and current topic id.&lt;br /&gt;
&lt;br /&gt;
However, if the assignment did not have reviews that vary by round or topic, these values would be nil on the AQ, and the previous query would fail.&lt;br /&gt;
&lt;br /&gt;
To fix this, we modified the ''assignment_questionnaire'' function in the AssignmentForm model to check the Assignment's ''vary_by_round'' and ''vary_by_topic'' flags, and then add the corresponding fields to the query. &lt;br /&gt;
&lt;br /&gt;
This means that:&lt;br /&gt;
* If an assignment does not vary by round or by topic, the query for AQs will be by assignment id only.&lt;br /&gt;
* If the assignment varies by round but not topic, the query for AQs will be by assignment id and round number.&lt;br /&gt;
* etc..&lt;br /&gt;
&lt;br /&gt;
[[File:AQNewImpl.PNG]]&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we would need to modify existing code as well as add new code. To ensure that existing functionality is not broken, and new functionality works as expected, we will be using the following Test Strategy (which was also used by previous team):&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files will be modified and they should all pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*As part of previous implementation, the team had introduced the following new RSpec test files. We plan to use these rspec files.&lt;br /&gt;
**spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
**spec/models/self_review_response_map_spec.rb&lt;br /&gt;
*All these rspec tests should pass for us to complete the testing.&lt;br /&gt;
&lt;br /&gt;
===Test the updated/new features on Expertiza UI instance===&lt;br /&gt;
*Since the changes in the project would be related to topics, and rubrics for assignment, those features will be tested in Expertiza UI. Current view of Topics and Rubrics tab looks as follows:&lt;br /&gt;
[[File:Edit assignment rubric.png]]&lt;br /&gt;
[[File:Edit assignment topic.png]]&lt;br /&gt;
&lt;br /&gt;
Once the changes are implemented, additional check boxes, and dropdown fields will be added in both these tabs. For example: as shown in the following screenshot, we will have an additional check box '''&amp;quot;Review rubric varies by topic?&amp;quot;''' in the Rubrics tab.&lt;br /&gt;
&lt;br /&gt;
[[File:Ui testing checkbox.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the check box '''&amp;quot;Review rubric varies by topic?&amp;quot;''' is checked, a new '''Questionnaire''' column with drop down menu will be added in the Topics tab as shown in the screenshot below taken from the previous team's implementation demo.&lt;br /&gt;
&lt;br /&gt;
[[File:Ui testing checkbox selected topics.png]]&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
As can be seen from [https://coveralls.io/jobs/61850438 Coverall], our changes have increased the code coverage by 21.1% to 51.615%.&lt;br /&gt;
&lt;br /&gt;
== Future Work==&lt;br /&gt;
After merging the previous team's work with expertiza, several RSpec tests failed.&lt;br /&gt;
*This was due to how questionnaires were retrieved/found for an assignment. Staggered deadlines also rely on finding questionnaires using topic id, which isn't handled until after an assignment is made.&lt;br /&gt;
*'''Resolved'''&lt;br /&gt;
However, undoing filtering results in even more errors across models, controllers, and forms. This feature, however is a quality of life improvement and is less of a priority.&lt;br /&gt;
* '''Unresolved'''&lt;br /&gt;
Another quality of life improvement is that staggered deadlines and topics cannot be added to an assignment until after the assignment has been created and saved.&lt;br /&gt;
* This issue exists on expertiza's beta branch itself, separate from our changes.&lt;br /&gt;
*'''Unresolved'''&lt;br /&gt;
&lt;br /&gt;
==Useful Links==&lt;br /&gt;
*'''Github''': https://github.com/abhishekupadhyaya/expertiza&lt;br /&gt;
*'''Pull Request''': https://github.com/expertiza/expertiza/pull/1720&lt;br /&gt;
*'''Demo Recording''': https://www.youtube.com/watch?v=3Ns3DYGtJdQ&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134293</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134293"/>
		<updated>2020-04-25T04:32:24Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Previous Implementation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes designed, and implemented for [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for CSC/ECE 517, Spring 2020.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://youtu.be/3Ns3DYGtJdQ&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
This feature was previously implemented and was detailed [http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics here]. The feature concluded with allowing 4 rubric scenarios for an assignment:&lt;br /&gt;
*Rubric does not vary by round or by topic.&lt;br /&gt;
*Rubric varies by round, but not by topic.&lt;br /&gt;
*Rubric varies by topic, but not by round.&lt;br /&gt;
*Rubric varies by both round and topic.&lt;br /&gt;
However, there were two issues with the implementation:&lt;br /&gt;
*Rubrics in the dropdown were only those created by the logged-in instructor, so the TA wouldn’t be able to see them&lt;br /&gt;
*Rubrics would not be saved after selecting them and saving.&lt;br /&gt;
In light of these issues, [https://github.com/gabalmat/expertiza/commit/23ed2cca2976f55515ea8980646e4432858bf446 changes] to expertiza were made as follows:&lt;br /&gt;
*Two additional columns are added into the Assignment table that determines whether Rubrics varies by either Round or Topic with default values False&lt;br /&gt;
*'''update_assignment_questionnaires''' method is re-implemented&lt;br /&gt;
**Having extra column in the assignment questionnaire table topic_id, no need for deleting all the data and re-writing it again every single time in the DB (this caused the previous implementation to have a delay when selecting **rubrics)&lt;br /&gt;
**The only varying value is questionnaire_id, the rest values may not change from Topics or Rubrics tabs, but can be added&lt;br /&gt;
*There are 4 (four) possible cases for saving and updating data:&lt;br /&gt;
**used_in_round = null and topic_id = null&lt;br /&gt;
**used_in_round = integer and topic_id = null&lt;br /&gt;
**used_in_round = null and topic_id = integer&lt;br /&gt;
**used_in_round = integer and topic_id = integer&lt;br /&gt;
This solved the issue of having rubrics save&lt;br /&gt;
===Problem===&lt;br /&gt;
The feature we have to implement was not fully committed due to the previously mentioned problems, so we have to reincorporate the missing code. However, a resulting issue is the inability for an instructor or TA to use rubrics that they did not create. The current problem can be broken down into the following parts:&lt;br /&gt;
# Integrate the changes made from the original implementation into the current version of Expertiza&lt;br /&gt;
# Allow an instructor/TA to chose rubrics that aren’t only theirs&lt;br /&gt;
# Create and update tests to reflect the changes as needed&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
Our proposed solution keeps the previous implementation, but changes rubric filtering to allow instructors/TAs to use filters that are not theirs. Alongside the changes in the original implementation we propose:&lt;br /&gt;
*Allow an instructor to choose different rubrics for different topics&lt;br /&gt;
**PROBLEM: The drop-downs for selecting rubrics show only those rubrics created by the currently-logged in instructor (per project mentor). &lt;br /&gt;
***SOLUTION: Change the filtering in the questionnaire_options method to reflect the desired filtering.&lt;br /&gt;
***FILE: app/helpers/assignment_helper.rb&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
Since our project is to improve upon a previous implementation that was slightly flawed, we will be modifying all of the same files that they previously modified (even if we don’t choose to alter their implementation in that file).&lt;br /&gt;
&lt;br /&gt;
The major modified files from the previous implementation include:&lt;br /&gt;
*'''app/controllers/assignments_controller.rb''': To refresh the topics list when changing tabs&lt;br /&gt;
*'''app/controllers/popup_controller.rb''': To add a potential error message to the rubric view scores popup&lt;br /&gt;
*'''app/helpers/assignment_helper.rb''': To add a topic id to the searchable fields for a questionnaire&lt;br /&gt;
*'''app/models/assignment.rb''': Add methods to determine if an assignment varies by rubric/topic. (will be refactored as part of our change, however)&lt;br /&gt;
*'''app/models/assignment_form.rb''': Add topic ids to created assignment questionnaires&lt;br /&gt;
*'''app/models/assignment_questionnaire.rb''': Add topic id to assignment questionnaire model&lt;br /&gt;
*'''app/models/review_response_map.rb''': To allow finding review questionnaires by topic id&lt;br /&gt;
*'''app/models/sign_up_topic.rb''': To allow a topic to have many assignment questionnaires attach to it (via topic id)&lt;br /&gt;
*'''app/views/assignments/edit.html.erb''': To move topic editing view to its own file that is rendered as part of assignment edit&lt;br /&gt;
*'''app/views/assignments/edit/_rubrics.html.erb''': Factor out common code into a function, update to use topic id&lt;br /&gt;
*'''app/views/assignments/edit/_topics.html.erb''': Topic editing view that was moved from assignment edit view&lt;br /&gt;
*'''app/views/popup/view_review_scores_popup.html.erb''': Assignments that vary by topic should not be displayed, instead getting error&lt;br /&gt;
*'''app/views/sign_up_sheet/_table_line.html.erb''': Add questionnaires to signup sheet table if assignment varies by topic&lt;br /&gt;
*'''db/migrate/XXXXXXXXXXX_add_topic_id_to_assignment_questionnaires.rb''': Migration to add topic id to assignment questionnaire schema&lt;br /&gt;
*'''...As well as many test files related to the above changes'''&lt;br /&gt;
&lt;br /&gt;
To address the issues brought up with the previous implementation, we will also make the following major modifications:&lt;br /&gt;
*'''app/models/assignment.rb''': Add persisted fields to the assignment for varying by topic/round instead of using methods to determine it&lt;br /&gt;
*'''app/helpers/assignment_helper.rb''': Refactor by moving function to find questionnaire / assignment questionnaire to assignment_form.rb. Remove filters that only allow instructors to see rubrics.&lt;br /&gt;
*'''app/models/assignment_form.rb''': No longer delete all existing questionnaires on update, update them instead. Now find questionnaire by assignment questionnaire and type rather than assignment/type/round_number/topic_id.&lt;br /&gt;
*'''app/views/assignments/edit/_rubrics.html.erb''': Modify to set assignment vary by round/topic fields instead of non persisted flags&lt;br /&gt;
*'''db/migrate/XXXXXXXXX_add_vary_by_topic_to_assignments.rb''': Migration to add “vary by topic” field to assignment&lt;br /&gt;
*'''db/migrate/XXXXXXXXX_add_vary_by_round_to_assignments.rb''': Migration to add “vary by round” field to assignment &lt;br /&gt;
*'''app/controllers/assignments_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/controllers/grades_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/controllers/popup_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/helpers/grades_helper.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/helpers/summary_helper.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/assignment_participant.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/feedback_response_map.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/on_the_fly_calc.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/self_review_response_map.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/tag_prompt_deployment.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
We will be re-adding the database flow that was added in the previous implementation, linking ''sign_up_topic'' to ''assignment_questionnaire'' via a '''topic_id''' field.&lt;br /&gt;
[[File:HW04_table.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition to that, we will be adding two additional boolean fields to the ''assignment'' schema: '''vary_by_round''' and '''vary_by_topic'''. As discussed earlier, in the previous implementation, these were methods that were called to determine if an assignment varied by round/topic rather than a persisted value. &lt;br /&gt;
&lt;br /&gt;
[[File:E2026DatabaseFlow.png]]&lt;br /&gt;
&lt;br /&gt;
Only a subset of the fields for each table is shown in the diagram because most of the fields are not relevant to these changes and would only serve to distract from the relevant changes. Additions are shown in bold.&lt;br /&gt;
&lt;br /&gt;
==New Implementation==&lt;br /&gt;
While trying to integrate the previous team's implementation of this feature, we discovered that their method for querying AssignmentQuestionnaires (AQs) was flawed.&lt;br /&gt;
&lt;br /&gt;
It would always query for the AQs by assignment id, current round number, and current topic id.&lt;br /&gt;
&lt;br /&gt;
However, if the assignment did not have reviews that vary by round or topic, these values would be nil on the AQ, and the previous query would fail.&lt;br /&gt;
&lt;br /&gt;
To fix this, we modified the ''assignment_questionnaire'' function in the AssignmentForm model to check the Assignment's ''vary_by_round'' and ''vary_by_topic'' flags, and then add the corresponding fields to the query. &lt;br /&gt;
&lt;br /&gt;
This means that:&lt;br /&gt;
* If an assignment does not vary by round or by topic, the query for AQs will be by assignment id only.&lt;br /&gt;
* If the assignment varies by round but not topic, the query for AQs will be by assignment id and round number.&lt;br /&gt;
* etc..&lt;br /&gt;
&lt;br /&gt;
[[File:AQNewImpl.PNG]]&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we would need to modify existing code as well as add new code. To ensure that existing functionality is not broken, and new functionality works as expected, we will be using the following Test Strategy (which was also used by previous team):&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files will be modified and they should all pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*As part of previous implementation, the team had introduced the following new RSpec test files. We plan to use these rspec files.&lt;br /&gt;
**spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
**spec/models/self_review_response_map_spec.rb&lt;br /&gt;
*All these rspec tests should pass for us to complete the testing.&lt;br /&gt;
&lt;br /&gt;
===Test the updated/new features on Expertiza UI instance===&lt;br /&gt;
*Since the changes in the project would be related to topics, and rubrics for assignment, those features will be tested in Expertiza UI. Current view of Topics and Rubrics tab looks as follows:&lt;br /&gt;
[[File:Edit assignment rubric.png]]&lt;br /&gt;
[[File:Edit assignment topic.png]]&lt;br /&gt;
&lt;br /&gt;
Once the changes are implemented, additional check boxes, and dropdown fields will be added in both these tabs. For example: as shown in the following screenshot, we will have an additional check box '''&amp;quot;Review rubric varies by topic?&amp;quot;''' in the Rubrics tab.&lt;br /&gt;
&lt;br /&gt;
[[File:Ui testing checkbox.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the check box '''&amp;quot;Review rubric varies by topic?&amp;quot;''' is checked, a new '''Questionnaire''' column with drop down menu will be added in the Topics tab as shown in the screenshot below taken from the previous team's implementation demo.&lt;br /&gt;
&lt;br /&gt;
[[File:Ui testing checkbox selected topics.png]]&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
As can be seen from [https://coveralls.io/jobs/61850438 Coverall], our changes have increased the code coverage by 21.1% to 51.615%.&lt;br /&gt;
&lt;br /&gt;
== Future Work==&lt;br /&gt;
After merging the previous team's work with expertiza, several RSpec tests failed.&lt;br /&gt;
*This was due to how questionnaires were retrieved/found for an assignment. Staggered deadlines also rely on finding questionnaires using topic id, which isn't handled until after an assignment is made.&lt;br /&gt;
*'''Resolved'''&lt;br /&gt;
However, undoing filtering results in even more errors across models, controllers, and forms. This feature, however is a quality of life improvement and is less of a priority.&lt;br /&gt;
* '''Unresolved'''&lt;br /&gt;
Another quality of life improvement is that staggered deadlines and topics cannot be added to an assignment until after the assignment has been created and saved.&lt;br /&gt;
* This issue exists on expertiza's beta branch itself, separate from our changes.&lt;br /&gt;
*'''Unresolved'''&lt;br /&gt;
&lt;br /&gt;
==Useful Links==&lt;br /&gt;
*'''Github''': https://github.com/abhishekupadhyaya/expertiza&lt;br /&gt;
*'''Pull Request''': https://github.com/expertiza/expertiza/pull/1720&lt;br /&gt;
*'''Demo Recording''': https://www.youtube.com/watch?v=LukuCG5XBl8&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134138</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=134138"/>
		<updated>2020-04-25T02:51:05Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes planned for [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for CSC/ECE 517, Spring 2020.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://www.youtube.com/watch?v=F7nQsIUspQM&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
This feature was previously implemented and was detailed [http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics here]. The feature concluded with allowing 4 rubric scenarios for an assignment:&lt;br /&gt;
*Rubric does not vary by round or by topic.&lt;br /&gt;
*Rubric varies by round, but not by topic.&lt;br /&gt;
*Rubric varies by topic, but not by round.&lt;br /&gt;
*Rubric varies by both round and topic.&lt;br /&gt;
However, there were two issues with the implementation:&lt;br /&gt;
*Rubrics in the dropdown were only those created by the logged-in instructor, so the TA wouldn’t be able to see them&lt;br /&gt;
*Rubrics would not be saved after selecting them and saving.&lt;br /&gt;
In light of these issues, [https://github.com/gabalmat/expertiza/commit/23ed2cca2976f55515ea8980646e4432858bf446 changes] to expertiza were made as follows:&lt;br /&gt;
*Two additional columns are added into the Assignment table that determines whether Rubrics varies by either Round or Topic with default values False&lt;br /&gt;
*'''update_assignment_questionnaires''' method is re-implemented&lt;br /&gt;
**Having extra column in the assignment questionnaire table topic_id, no need for deleting all the data and re-writing it again every single time in the DB (this caused the previous implementation to have a delay when selecting **rubrics)&lt;br /&gt;
**The only varying value is questionnaire_id, the rest values may not change from Topics or Rubrics tabs, but can be added&lt;br /&gt;
*There are 4 (four) possible cases for saving and updating data:&lt;br /&gt;
**used_in_round = null and topic_id = null&lt;br /&gt;
**used_in_round = integer and topic_id = null&lt;br /&gt;
**used_in_round = null and topic_id = integer&lt;br /&gt;
**used_in_round = integer and topic_id = integer&lt;br /&gt;
This solved the issue of having rubrics save&lt;br /&gt;
===Problem===&lt;br /&gt;
The feature we have to implement was not fully committed due to the previously mentioned problems, so we have to reincorporate the missing code. However, a resulting issue is the inability for an instructor or TA to use rubrics that they did not create. The current problem can be broken down into the following parts:&lt;br /&gt;
# Integrate the changes made from the original implementation into the current version of Expertiza&lt;br /&gt;
# Allow an instructor/TA to chose rubrics that aren’t only theirs&lt;br /&gt;
# Create and update tests to reflect the changes as needed&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
Our proposed solution keeps the previous implementation, but changes rubric filtering to allow instructors/TAs to use filters that are not theirs. Alongside the changes in the original implementation we propose:&lt;br /&gt;
*Allow an instructor to choose different rubrics for different topics&lt;br /&gt;
**PROBLEM: The drop-downs for selecting rubrics show only those rubrics created by the currently-logged in instructor (per project mentor). &lt;br /&gt;
***SOLUTION: Change the filtering in the questionnaire_options method to reflect the desired filtering.&lt;br /&gt;
***FILE: app/helpers/assignment_helper.rb&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
Since our project is to improve upon a previous implementation that was slightly flawed, we will be modifying all of the same files that they previously modified (even if we don’t choose to alter their implementation in that file).&lt;br /&gt;
&lt;br /&gt;
The major modified files from the previous implementation include:&lt;br /&gt;
*'''app/controllers/assignments_controller.rb''': To refresh the topics list when changing tabs&lt;br /&gt;
*'''app/controllers/popup_controller.rb''': To add a potential error message to the rubric view scores popup&lt;br /&gt;
*'''app/helpers/assignment_helper.rb''': To add a topic id to the searchable fields for a questionnaire&lt;br /&gt;
*'''app/models/assignment.rb''': Add methods to determine if an assignment varies by rubric/topic. (will be refactored as part of our change, however)&lt;br /&gt;
*'''app/models/assignment_form.rb''': Add topic ids to created assignment questionnaires&lt;br /&gt;
*'''app/models/assignment_questionnaire.rb''': Add topic id to assignment questionnaire model&lt;br /&gt;
*'''app/models/review_response_map.rb''': To allow finding review questionnaires by topic id&lt;br /&gt;
*'''app/models/sign_up_topic.rb''': To allow a topic to have many assignment questionnaires attach to it (via topic id)&lt;br /&gt;
*'''app/views/assignments/edit.html.erb''': To move topic editing view to its own file that is rendered as part of assignment edit&lt;br /&gt;
*'''app/views/assignments/edit/_rubrics.html.erb''': Factor out common code into a function, update to use topic id&lt;br /&gt;
*'''app/views/assignments/edit/_topics.html.erb''': Topic editing view that was moved from assignment edit view&lt;br /&gt;
*'''app/views/popup/view_review_scores_popup.html.erb''': Assignments that vary by topic should not be displayed, instead getting error&lt;br /&gt;
*'''app/views/sign_up_sheet/_table_line.html.erb''': Add questionnaires to signup sheet table if assignment varies by topic&lt;br /&gt;
*'''db/migrate/XXXXXXXXXXX_add_topic_id_to_assignment_questionnaires.rb''': Migration to add topic id to assignment questionnaire schema&lt;br /&gt;
*'''...As well as many test files related to the above changes'''&lt;br /&gt;
&lt;br /&gt;
To address the issues brought up with the previous implementation, we will also make the following major modifications:&lt;br /&gt;
*'''app/models/assignment.rb''': Add persisted fields to the assignment for varying by topic/round instead of using methods to determine it&lt;br /&gt;
*'''app/helpers/assignment_helper.rb''': Refactor by moving function to find questionnaire / assignment questionnaire to assignment_form.rb. Remove filters that only allow instructors to see rubrics.&lt;br /&gt;
*'''app/models/assignment_form.rb''': No longer delete all existing questionnaires on update, update them instead. Now find questionnaire by assignment questionnaire and type rather than assignment/type/round_number/topic_id.&lt;br /&gt;
*'''app/views/assignments/edit/_rubrics.html.erb''': Modify to set assignment vary by round/topic fields instead of non persisted flags&lt;br /&gt;
*'''db/migrate/XXXXXXXXX_add_vary_by_topic_to_assignments.rb''': Migration to add “vary by topic” field to assignment&lt;br /&gt;
*'''db/migrate/XXXXXXXXX_add_vary_by_round_to_assignments.rb''': Migration to add “vary by round” field to assignment &lt;br /&gt;
*'''app/controllers/assignments_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/controllers/grades_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/controllers/popup_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/helpers/grades_helper.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/helpers/summary_helper.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/assignment_participant.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/feedback_response_map.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/on_the_fly_calc.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/self_review_response_map.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/models/tag_prompt_deployment.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
We will be re-adding the database flow that was added in the previous implementation, linking ''sign_up_topic'' to ''assignment_questionnaire'' via a '''topic_id''' field.&lt;br /&gt;
[[File:HW04_table.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In addition to that, we will be adding two additional boolean fields to the ''assignment'' schema: '''vary_by_round''' and '''vary_by_topic'''. As discussed earlier, in the previous implementation, these were methods that were called to determine if an assignment varied by round/topic rather than a persisted value. &lt;br /&gt;
&lt;br /&gt;
[[File:E2026DatabaseFlow.png]]&lt;br /&gt;
&lt;br /&gt;
Only a subset of the fields for each table is shown in the diagram because most of the fields are not relevant to these changes and would only serve to distract from the relevant changes. Additions are shown in bold.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we would need to modify existing code as well as add new code. To ensure that existing functionality is not broken, and new functionality works as expected, we will be using the following Test Strategy (which was also used by previous team):&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*The following existing RSpec test files will be modified and they should all pass as part of testing:&lt;br /&gt;
**spec/controllers/assignments_controller_spec.rb&lt;br /&gt;
**spec/controllers/questionnaires_controller_spec.rb&lt;br /&gt;
**spec/controllers/response_controller_spec.rb&lt;br /&gt;
**spec/factories/factories.rb&lt;br /&gt;
**spec/features/assignment_creation_spec.rb&lt;br /&gt;
**spec/features/quiz_spec.rb&lt;br /&gt;
**spec/features/staggered_deadline_spec.rb&lt;br /&gt;
**spec/models/assignment_form_spec.rb&lt;br /&gt;
**spec/models/assignment_spec.rb&lt;br /&gt;
**spec/models/on_the_fly_calc_spec.rb&lt;br /&gt;
**spec/models/response_spec.rb&lt;br /&gt;
**spec/models/review_response_map_spec.rb&lt;br /&gt;
&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*As part of previous implementation, the team had introduced the following new RSpec test files. We plan to use these rspec files.&lt;br /&gt;
**spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
**spec/models/self_review_response_map_spec.rb&lt;br /&gt;
*All these rspec tests should pass for us to complete the testing.&lt;br /&gt;
&lt;br /&gt;
===Test the updated/new features on Expertiza UI instance===&lt;br /&gt;
*Since the changes in the project would be related to topics, and rubrics for assignment, those features will be tested in Expertiza UI. Current view of Topics and Rubrics tab looks as follows:&lt;br /&gt;
[[File:Edit assignment rubric.png]]&lt;br /&gt;
[[File:Edit assignment topic.png]]&lt;br /&gt;
&lt;br /&gt;
Once the changes are implemented, additional check boxes, and dropdown fields will be added in both these tabs. For example: as shown in the following screenshot, we will have an additional check box '''&amp;quot;Review rubric varies by topic?&amp;quot;''' in the Rubrics tab.&lt;br /&gt;
&lt;br /&gt;
[[File:Ui testing checkbox.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When the check box '''&amp;quot;Review rubric varies by topic?&amp;quot;''' is checked, a new '''Questionnaire''' column with drop down menu will be added in the Topics tab as shown in the screenshot below taken from the previous team's implementation demo.&lt;br /&gt;
&lt;br /&gt;
[[File:Ui testing checkbox selected topics.png]]&lt;br /&gt;
&lt;br /&gt;
== Obstacles ==&lt;br /&gt;
While resolving tests for the Travis build to pass, we finally reached:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This error does not appear on the local tests, so it is out of our control and related to Travis itself.&lt;br /&gt;
&lt;br /&gt;
== Future Work==&lt;br /&gt;
After merging the previous team's work with expertiza, several RSpec tests failed.&lt;br /&gt;
*This was due to how questionnaires were retrieved/found for an assignment. Staggered deadlines also rely on finding questionnaires using topic id, which isn't handled until after an assignment is made.&lt;br /&gt;
*'''Resolved'''&lt;br /&gt;
However, undoing filtering results in even more errors across models, controllers, and forms. This feature, however is a quality of life improvement and is less of a priority.&lt;br /&gt;
* '''Unresolved'''&lt;br /&gt;
Another quality of life improvement is that staggered deadlines and topics cannot be added to an assignment until after the assignment has been created and saved.&lt;br /&gt;
* This issue exists on expertiza's beta branch itself, separate from our changes.&lt;br /&gt;
*'''Unresolved'''&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020&amp;diff=133122</id>
		<title>CSC/ECE 517 Spring 2020</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020&amp;diff=133122"/>
		<updated>2020-04-09T01:35:03Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[CSC/ECE_517_Spring_2020_-_E2000._Refactor_stage_deadlines_in_assignment.rb]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring 2020 - E2014. Refactor datetimepicker.js]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2020/E2012._refactor_lottery_controller.rb]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2020/P2000.Refactor_pyrh_oauth_capabilities_to_a_separate_class]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring 2020 - E2015. Conflict notification]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2020/P2000.Refactor_pyrh_oauth_capabilities_to_use_marshmallow]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types]]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020&amp;diff=133120</id>
		<title>CSC/ECE 517 Spring 2020</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020&amp;diff=133120"/>
		<updated>2020-04-09T01:33:46Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[CSC/ECE_517_Spring_2020_-_E2000._Refactor_stage_deadlines_in_assignment.rb]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring 2020 - E2014. Refactor datetimepicker.js]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2020/E2012._refactor_lottery_controller.rb]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2020/P2000.Refactor_pyrh_oauth_capabilities_to_a_separate_class]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring 2020 - E2015. Conflict notification]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE_517_Spring_2020/P2000.Refactor_pyrh_oauth_capabilities_to_use_marshmallow]]&lt;br /&gt;
[[CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types]]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=133118</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=133118"/>
		<updated>2020-04-09T01:20:14Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Purpose==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://www.youtube.com/watch?v=F7nQsIUspQM&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
This feature was previously implemented and was detailed [http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics here]. The feature concluded with allowing 4 rubric scenarios for an assignment:&lt;br /&gt;
*Rubric does not vary by round or by topic.&lt;br /&gt;
*Rubric varies by round, but not by topic.&lt;br /&gt;
*Rubric varies by topic, but not by round.&lt;br /&gt;
*Rubric varies by both round and topic.&lt;br /&gt;
However, there were two issues with the implementation:&lt;br /&gt;
*Rubrics in the dropdown were only those created by the logged-in instructor, so the TA wouldn’t be able to see them&lt;br /&gt;
*Rubrics would not be saved after selecting them and saving.&lt;br /&gt;
In light of these issues, [https://github.com/gabalmat/expertiza/commit/23ed2cca2976f55515ea8980646e4432858bf446 changes] to expertiza were made as follows:&lt;br /&gt;
*Two additional columns are added into the Assignment table that determines whether Rubrics varies by either Round or Topic with default values False&lt;br /&gt;
*'''update_assignment_questionnaires''' method is re-implemented&lt;br /&gt;
**Having extra column in the assignment questionnaire table topic_id, no need for deleting all the data and re-writing it again every single time in the DB (this caused the previous implementation to have a delay when selecting **rubrics)&lt;br /&gt;
**The only varying value is questionnaire_id, the rest values may not change from Topics or Rubrics tabs, but can be added&lt;br /&gt;
*There are 4 (four) possible cases for saving and updating data:&lt;br /&gt;
**used_in_round = null and topic_id = null&lt;br /&gt;
**used_in_round = integer and topic_id = null&lt;br /&gt;
**used_in_round = null and topic_id = integer&lt;br /&gt;
**used_in_round = integer and topic_id = integer&lt;br /&gt;
This solved the issue of having rubrics save&lt;br /&gt;
===Problem===&lt;br /&gt;
The feature we have to implement was not fully committed due to the previously mentioned problems, so we have to reincorporate the missing code. However, a resulting issue is the inability for an instructor or TA to use rubrics that they did not create. The current problem can be broken down into the following parts:&lt;br /&gt;
# Integrate the changes made from the original implementation into the current version of Expertiza&lt;br /&gt;
# Allow an instructor/TA to chose rubrics that aren’t only theirs&lt;br /&gt;
# Create and update tests to reflect the changes as needed&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
Our proposed solution keeps the previous implementation, but changes rubric filtering to allow instructors/TAs to use filters that are not theirs. Alongside the changes in the original implementation we propose:&lt;br /&gt;
*Allow an instructor to choose different rubrics for different topics&lt;br /&gt;
**PROBLEM: The drop-downs for selecting rubrics show only those rubrics created by the currently-logged in instructor (per project mentor). &lt;br /&gt;
***SOLUTION: Change the filtering in the questionnaire_options method to reflect the desired filtering.&lt;br /&gt;
***FILE: app/helpers/assignment_helper.rb&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
Since our project is to improve upon a previous implementation that was slightly flawed, we will be modifying all of the same files that they previously modified (even if we don’t choose to alter their implementation in that file).&lt;br /&gt;
&lt;br /&gt;
The major modified files from the previous implementation include:&lt;br /&gt;
*'''app/controllers/assignments_controller.rb''': To refresh the topics list when changing tabs&lt;br /&gt;
*'''app/controllers/popup_controller.rb''': To add a potential error message to the rubric view scores popup&lt;br /&gt;
*'''app/helpers/assignment_helper.rb''': To add a topic id to the searchable fields for a questionnaire&lt;br /&gt;
*'''app/models/assignment.rb''': Add methods to determine if an assignment varies by rubric/topic. (will be refactored as part of our change, however)&lt;br /&gt;
*'''app/models/assignment_form.rb''': Add topic ids to created assignment questionnaires&lt;br /&gt;
*'''app/models/assignment_questionnaire.rb''': Add topic id to assignment questionnaire model&lt;br /&gt;
*'''app/models/review_response_map.rb''': To allow finding review questionnaires by topic id&lt;br /&gt;
*'''app/models/sign_up_topic.rb''': To allow a topic to have many assignment questionnaires attach to it (via topic id)&lt;br /&gt;
*'''app/views/assignments/edit.html.erb''': To move topic editing view to its own file that is rendered as part of assignment edit&lt;br /&gt;
*'''app/views/assignments/edit/_rubrics.html.erb''': Factor out common code into a function, update to use topic id&lt;br /&gt;
*'''app/views/assignments/edit/_topics.html.erb''': Topic editing view that was moved from assignment edit view&lt;br /&gt;
*'''app/views/popup/view_review_scores_popup.html.erb''': Assignments that vary by topic should not be displayed, instead getting error&lt;br /&gt;
*'''app/views/sign_up_sheet/_table_line.html.erb''': Add questionnaires to signup sheet table if assignment varies by topic&lt;br /&gt;
*'''db/migrate/XXXXXXXXXXX_add_topic_id_to_assignment_questionnaires.rb''': Migration to add topic id to assignment questionnaire schema&lt;br /&gt;
*'''...As well as many test files related to the above changes'''&lt;br /&gt;
&lt;br /&gt;
To address the issues brought up with the previous implementation, we will also make the following major modifications:&lt;br /&gt;
*'''app/models/assignment.rb''': Add persisted fields to the assignment for varying by topic/round instead of using methods to determine it&lt;br /&gt;
*'''app/helpers/assignment_helper.rb''': Refactor by moving function to find questionnaire / assignment questionnaire to assignment_form.rb. Remove filters that only allow instructors to see rubrics.&lt;br /&gt;
*'''app/models/assignment_form.rb''': No longer delete all existing questionnaires on update, update them instead. Now find questionnaire by assignment questionnaire and type rather than assignment/type/round_number/topic_id.&lt;br /&gt;
*'''app/views/assignments/edit/_rubrics.html.erb''': Modify to set assignment vary by round/topic fields instead of non persisted flags&lt;br /&gt;
*'''db/migrate/XXXXXXXXX_add_vary_by_topic_to_assignments.rb''': Migration to add “vary by topic” field to assignment&lt;br /&gt;
*'''db/migrate/XXXXXXXXX_add_vary_by_round_to_assignments.rb''': Migration to add “vary by round” field to assignment &lt;br /&gt;
*'''app/controllers/assignments_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/controllers/grades_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/controllers/popup_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''...Several other files need the above refactor as well'''&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
We will be re-adding the database flow that was added in the previous implementation, linking ''sign_up_topic'' to ''assignment_questionnaire'' via a '''topic_id''' field.&lt;br /&gt;
&lt;br /&gt;
In addition to that, we will be adding two additional boolean fields to the ''assignment'' schema: '''vary_by_round''' and '''vary_by_topic'''. As discussed earlier, in the previous implementation, these were methods that were called to determine if an assignment varied by round/topic rather than a persisted value. &lt;br /&gt;
&lt;br /&gt;
[[File:E2026DatabaseFlow.png]]&lt;br /&gt;
&lt;br /&gt;
Only a subset of the fields for each table is shown in the diagram because most of the fields are not relevant to these changes and would only serve to distract from the relevant changes. Additions are shown in bold.&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we would need to modify existing code as well as add new code. To ensure that existing functionality is not broken, and new functionality works as expected, we will be using the following Test Strategy (which was also used by previous team):&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*All the existing RSpec tests related to the files that have to be modified should pass.&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*As part of previous implementation, the team had introduced following new RSpec test files:&lt;br /&gt;
**spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
**spec/models/self_review_response_map_spec.rb&lt;br /&gt;
*We plan to use those rspec files as well as implement new ones that might be required once we start on our implementation.&lt;br /&gt;
*All these rspec tests should pass for us to complete the testing.&lt;br /&gt;
===Test the updated/new features on Expertiza UI instance===&lt;br /&gt;
*Since the changes in the project would be related to topics, and rubrics for assignment, those features will be tested in Expertiza UI. Current view of Topics and Rubrics tab looks as follows:&lt;br /&gt;
[[File:Edit assignment rubric.png]]&lt;br /&gt;
[[File:Edit assignment topic.png]]&lt;br /&gt;
&lt;br /&gt;
Additional check boxes, and dropdown fields will be added in both these tabs once we implement the changes. Those changes in the view as well as their functionality should be tested.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=133113</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=133113"/>
		<updated>2020-04-09T01:13:38Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Design Strategy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://www.youtube.com/watch?v=F7nQsIUspQM&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
This feature was previously implemented and was detailed [http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics here]. The feature concluded with allowing 4 rubric scenarios for an assignment:&lt;br /&gt;
*Rubric does not vary by round or by topic.&lt;br /&gt;
*Rubric varies by round, but not by topic.&lt;br /&gt;
*Rubric varies by topic, but not by round.&lt;br /&gt;
*Rubric varies by both round and topic.&lt;br /&gt;
However, there were two issues with the implementation:&lt;br /&gt;
*Rubrics in the dropdown were only those created by the logged-in instructor, so the TA wouldn’t be able to see them&lt;br /&gt;
*Rubrics would not be saved after selecting them and saving.&lt;br /&gt;
In light of these issues, [https://github.com/gabalmat/expertiza/commit/23ed2cca2976f55515ea8980646e4432858bf446 changes] to expertiza were made as follows:&lt;br /&gt;
*Two additional columns are added into the Assignment table that determines whether Rubrics varies by either Round or Topic with default values False&lt;br /&gt;
*'''update_assignment_questionnaires''' method is re-implemented&lt;br /&gt;
**Having extra column in the assignment questionnaire table topic_id, no need for deleting all the data and re-writing it again every single time in the DB (this caused the previous implementation to have a delay when selecting **rubrics)&lt;br /&gt;
**The only varying value is questionnaire_id, the rest values may not change from Topics or Rubrics tabs, but can be added&lt;br /&gt;
*There are 4 (four) possible cases for saving and updating data:&lt;br /&gt;
**used_in_round = null and topic_id = null&lt;br /&gt;
**used_in_round = integer and topic_id = null&lt;br /&gt;
**used_in_round = null and topic_id = integer&lt;br /&gt;
**used_in_round = integer and topic_id = integer&lt;br /&gt;
This solved the issue of having rubrics save&lt;br /&gt;
===Problem===&lt;br /&gt;
The feature we have to implement was not fully committed due to the previously mentioned problems, so we have to reincorporate the missing code. However, a resulting issue is the inability for an instructor or TA to use rubrics that they did not create. The current problem can be broken down into the following parts:&lt;br /&gt;
# Integrate the changes made from the original implementation into the current version of Expertiza&lt;br /&gt;
# Allow an instructor/TA to chose rubrics that aren’t only theirs&lt;br /&gt;
# Create and update tests to reflect the changes as needed&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
Our proposed solution keeps the previous implementation, but changes rubric filtering to allow instructors/TAs to use filters that are not theirs. Alongside the changes in the original implementation we propose:&lt;br /&gt;
*Allow an instructor to choose different rubrics for different topics&lt;br /&gt;
**PROBLEM: The drop-downs for selecting rubrics show only those rubrics created by the currently-logged in instructor (per project mentor). &lt;br /&gt;
***SOLUTION: Change the filtering in the questionnaire_options method to reflect the desired filtering.&lt;br /&gt;
***FILE: app/helpers/assignment_helper.rb&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
Since our project is to improve upon a previous implementation that was slightly flawed, we will be modifying all of the same files that they previously modified (even if we don’t choose to alter their implementation in that file).&lt;br /&gt;
&lt;br /&gt;
The major modified files from the previous implementation include:&lt;br /&gt;
*'''app/controllers/assignments_controller.rb''': To refresh the topics list when changing tabs&lt;br /&gt;
*'''app/controllers/popup_controller.rb''': To add a potential error message to the rubric view scores popup&lt;br /&gt;
*'''app/helpers/assignment_helper.rb''': To add a topic id to the searchable fields for a questionnaire&lt;br /&gt;
*'''app/models/assignment.rb''': Add methods to determine if an assignment varies by rubric/topic. (will be refactored as part of our change, however)&lt;br /&gt;
*'''app/models/assignment_form.rb''': Add topic ids to created assignment questionnaires&lt;br /&gt;
*'''app/models/assignment_questionnaire.rb''': Add topic id to assignment questionnaire model&lt;br /&gt;
*'''app/models/review_response_map.rb''': To allow finding review questionnaires by topic id&lt;br /&gt;
*'''app/models/sign_up_topic.rb''': To allow a topic to have many assignment questionnaires attach to it (via topic id)&lt;br /&gt;
*'''app/views/assignments/edit.html.erb''': To move topic editing view to its own file that is rendered as part of assignment edit&lt;br /&gt;
*'''app/views/assignments/edit/_rubrics.html.erb''': Factor out common code into a function, update to use topic id&lt;br /&gt;
*'''app/views/assignments/edit/_topics.html.erb''': Topic editing view that was moved from assignment edit view&lt;br /&gt;
*'''app/views/popup/view_review_scores_popup.html.erb''': Assignments that vary by topic should not be displayed, instead getting error&lt;br /&gt;
*'''app/views/sign_up_sheet/_table_line.html.erb''': Add questionnaires to signup sheet table if assignment varies by topic&lt;br /&gt;
*'''db/migrate/XXXXXXXXXXX_add_topic_id_to_assignment_questionnaires.rb''': Migration to add topic id to assignment questionnaire schema&lt;br /&gt;
*'''...As well as many test files related to the above changes'''&lt;br /&gt;
&lt;br /&gt;
To address the issues brought up with the previous implementation, we will also make the following major modifications:&lt;br /&gt;
*'''app/models/assignment.rb''': Add persisted fields to the assignment for varying by topic/round instead of using methods to determine it&lt;br /&gt;
*'''app/helpers/assignment_helper.rb''': Refactor by moving function to find questionnaire / assignment questionnaire to assignment_form.rb. Remove filters that only allow instructors to see rubrics.&lt;br /&gt;
*'''app/models/assignment_form.rb''': No longer delete all existing questionnaires on update, update them instead. Now find questionnaire by assignment questionnaire and type rather than assignment/type/round_number/topic_id.&lt;br /&gt;
*'''app/views/assignments/edit/_rubrics.html.erb''': Modify to set assignment vary by round/topic fields instead of non persisted flags&lt;br /&gt;
*'''db/migrate/XXXXXXXXX_add_vary_by_topic_to_assignments.rb''': Migration to add “vary by topic” field to assignment&lt;br /&gt;
*'''db/migrate/XXXXXXXXX_add_vary_by_round_to_assignments.rb''': Migration to add “vary by round” field to assignment &lt;br /&gt;
*'''app/controllers/assignments_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/controllers/grades_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''app/controllers/popup_controller.rb''': Refactor to use the persisted assignment fields for varying by topic/round instead of using methods&lt;br /&gt;
*'''...Several other files need the above refactor as well'''&lt;br /&gt;
*'''All of the related test files to accommodate the above changes'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we would need to modify existing code as well as add new code. To ensure that existing functionality is not broken, and new functionality works as expected, we will be using the following Test Strategy (which was also used by previous team):&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*All the existing RSpec tests related to the files that have to be modified should pass.&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*As part of previous implementation, the team had introduced following new RSpec test files:&lt;br /&gt;
**spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
**spec/models/self_review_response_map_spec.rb&lt;br /&gt;
*We plan to use those rspec files as well as implement new ones that might be required once we start on our implementation.&lt;br /&gt;
*All these rspec tests should pass for us to complete the testing.&lt;br /&gt;
===Test the updated/new features on Expertiza UI instance===&lt;br /&gt;
*Since the changes in the project would be related to topics, and rubrics for assignment, those features will be tested in Expertiza UI. Current view of Topics and Rubrics tab looks as follows:&lt;br /&gt;
[[File:Edit assignment rubric.png]]&lt;br /&gt;
[[File:Edit assignment topic.png]]&lt;br /&gt;
&lt;br /&gt;
Additional check boxes, and dropdown fields will be added in both these tabs once we implement the changes. Those changes in the view as well as their functionality should be tested.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=133109</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=133109"/>
		<updated>2020-04-09T01:05:00Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Design Strategy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://www.youtube.com/watch?v=F7nQsIUspQM&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
This feature was previously implemented and was detailed [http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics here]. The feature concluded with allowing 4 rubric scenarios for an assignment:&lt;br /&gt;
*Rubric does not vary by round or by topic.&lt;br /&gt;
*Rubric varies by round, but not by topic.&lt;br /&gt;
*Rubric varies by topic, but not by round.&lt;br /&gt;
*Rubric varies by both round and topic.&lt;br /&gt;
However, there were two issues with the implementation:&lt;br /&gt;
*Rubrics in the dropdown were only those created by the logged-in instructor, so the TA wouldn’t be able to see them&lt;br /&gt;
*Rubrics would not be saved after selecting them and saving.&lt;br /&gt;
In light of these issues, [https://github.com/gabalmat/expertiza/commit/23ed2cca2976f55515ea8980646e4432858bf446 changes] to expertiza were made as follows:&lt;br /&gt;
*Two additional columns are added into the Assignment table that determines whether Rubrics varies by either Round or Topic with default values False&lt;br /&gt;
*update_assignment_questionnaires method is re-implemented&lt;br /&gt;
**Having extra column in the QA table topic_id, no need for deleting all the data and re-writing it again every single time in the DB (this caused the previous implementation to have a delay when selecting **rubrics)&lt;br /&gt;
**The only varying value is questionnaire_id, the rest values may not change from Topics or Rubrics tabs, but can be added&lt;br /&gt;
*There are 4 (four) possible cases for saving and updating data:&lt;br /&gt;
**used_in_round = null and topic_id = null&lt;br /&gt;
**used_in_round = integer and topic_id = null&lt;br /&gt;
**used_in_round = null and topic_id = integer&lt;br /&gt;
**used_in_round = integer and topic_id = integer&lt;br /&gt;
This solved the issue of having rubrics save&lt;br /&gt;
===Problem===&lt;br /&gt;
The feature we have to implement was not fully committed due to the previously mentioned problems, so we have to reincorporate the missing code. However, a resulting issue is the inability for an instructor or TA to use rubrics that they did not create. The current problem can be broken down into the following parts:&lt;br /&gt;
# Integrate the changes made from the original implementation into the current version of Expertiza&lt;br /&gt;
# Allow an instructor/TA to chose rubrics that aren’t only theirs&lt;br /&gt;
# Create and update tests to reflect the changes as needed&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
Our proposed solution keeps the previous implementation, but changes rubric filtering to allow instructors/TAs to use filters that are not theirs. Alongside the changes in the original implementation we propose:&lt;br /&gt;
*Allow an instructor to choose different rubrics for different topics&lt;br /&gt;
**PROBLEM: The drop-downs for selecting rubrics show only those rubrics created by the currently-logged in instructor (per project mentor). &lt;br /&gt;
***SOLUTION: Change the filtering in the questionnaire_options method to reflect the desired filtering.&lt;br /&gt;
***FILE: app/helpers/assignment_helper.rb&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we would need to modify existing code as well as add new code. To ensure that existing functionality is not broken, and new functionality works as expected, we will be using the following Test Strategy (which was also used by previous team):&lt;br /&gt;
===Run and pass existing RSpec Tests===&lt;br /&gt;
*All the existing RSpec tests related to the files that have to be modified should pass.&lt;br /&gt;
===Develop New RSpec Tests===&lt;br /&gt;
*As part of previous implementation, the team had introduced following new RSpec test files:&lt;br /&gt;
**spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
**spec/models/self_review_response_map_spec.rb&lt;br /&gt;
*We plan to use those rspec files as well as implement new ones that might be required once we start on our implementation.&lt;br /&gt;
*All these rspec tests should pass for us to complete the testing.&lt;br /&gt;
===Test the updated/new features on Expertiza UI instance===&lt;br /&gt;
*Since the changes in the project would be related to topics, and rubrics for assignment, those features will be tested in Expertiza UI. Current view of Topics and Rubrics tab looks as follows:&lt;br /&gt;
[[File:Edit assignment rubric.png]]&lt;br /&gt;
[[File:Edit assignment topic.png]]&lt;br /&gt;
&lt;br /&gt;
Additional check boxes, and dropdown fields will be added in both these tabs once we implement the changes. Those changes in the view as well as their functionality should be tested.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=133103</id>
		<title>CSC/ECE 517 Spring 2020 - E2026. Specialized rubrics for different topic types</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2026._Specialized_rubrics_for_different_topic_types&amp;diff=133103"/>
		<updated>2020-04-09T00:58:49Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* UML Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of [https://docs.google.com/document/d/1PEackBQqIcNfvD5idGUtxA9PBqLD5zoaEViWhYcX7Oo/edit#heading=h.z86zstcoj6u7 E2026. Specialized rubrics for different topic types (e.g., Servo project, refactoring project)], a Final Project for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Background ==&lt;br /&gt;
In CSC/ECE 517, there are Expertiza-based course projects, Mozilla-based course projects, etc. However, currently, we can only specify one kind of rubric for all kinds of course projects. This means that refactoring projects, testing projects, and Mozilla projects need to use the same rubric.  We hope we could specify different rubrics to be used with different kinds of course projects.&lt;br /&gt;
&lt;br /&gt;
This project was implemented by another team in Spring 2019. We will be implementing our project on top of what was implemented by the previous team, and fix the issues that were found in their implementation. Information on what the previous team had worked on is described in the '''Previous Implementation''' section.&lt;br /&gt;
&lt;br /&gt;
== Previous Implementation==&lt;br /&gt;
All aspects of previous implementation were good, and their design was well appreciated. Their changes were also merged to '''expertiza:beta''' branch, but were later reverted since the specialized rubrics weren’t saved in the database. This [https://github.com/expertiza/expertiza/issues/1475 github issue] provides a detailed explanation to the problem.&lt;br /&gt;
&lt;br /&gt;
For us to get started, we were provided with following links from previous implementation:&lt;br /&gt;
*http://wiki.expertiza.ncsu.edu/index.php/E1936_Specialized_Rubrics&lt;br /&gt;
*https://github.com/gabalmat/expertiza/tree/beta&lt;br /&gt;
*https://github.com/expertiza/expertiza/pull/1444&lt;br /&gt;
*https://www.youtube.com/watch?v=F7nQsIUspQM&lt;br /&gt;
&lt;br /&gt;
==Design Strategy==&lt;br /&gt;
&lt;br /&gt;
==UML Diagram==&lt;br /&gt;
Following the [https://expertiza.csc.ncsu.edu/index.php/E1936_Specialized_Rubrics previous implementations's] footsteps, this diagram depicts the interactions between an instructor and an assignment. The instructor may edit, delete, copy, and other stuff (already existing in Expertiza). Alongside editing topics and due dates, the instructor can edit what rubrics are assigned to an assignment. The highlighted portions are of interest. The topics tab allows instructors to specify which rubric associates with each topic while the rubrics tab lets the instructor determine if the assignment will vary by topic or not.&lt;br /&gt;
&lt;br /&gt;
[[File:Use_case_diagram_1936.png]]&lt;br /&gt;
&lt;br /&gt;
==Files to be modified==&lt;br /&gt;
&lt;br /&gt;
==Database Flow==&lt;br /&gt;
&lt;br /&gt;
==Testing Plan==&lt;br /&gt;
As part of our implementation, we would need to modify existing code as well as add new code. To ensure that existing functionality is not broken, and new functionality works as expected, we will be using the following Test Strategy (which was also used by previous team):&lt;br /&gt;
*Run and pass existing RSpec Tests&lt;br /&gt;
**All the existing RSpec tests related to the files that have to be modified should pass.&lt;br /&gt;
*Develop New RSpec Tests&lt;br /&gt;
**As part of previous implementation, the team had introduced following new RSpec test files:&lt;br /&gt;
***spec/helpers/assignment_helper_spec.rb&lt;br /&gt;
***spec/models/self_review_response_map_spec.rb&lt;br /&gt;
**We plan to use those rspec files as well as implement new ones that might be required once we start on our implementation.&lt;br /&gt;
**All these rspec tests should pass for us to complete the testing.&lt;br /&gt;
*Test the updated/new features on Expertiza UI instance&lt;br /&gt;
**Since the changes in the project would be related to topics, and rubrics for assignment, those features will be tested in Expertiza UI. Current view of Topics and Rubrics tab looks as follows. Additional check boxes, or dropdown fields will be added in both these tabs once we implement the changes.&lt;br /&gt;
**[[File:Edit assignment rubric.png]]&lt;br /&gt;
**[[File:Edit assignment topic.png]]&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor''': Anuja Kulkarni&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132592</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132592"/>
		<updated>2020-04-01T01:34:12Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Additional Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. This controller is responsible for creating and changing assignments. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''assignment_form_save_handler''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method from 33 to 15. Assignment Branch Condition size was also reduced from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create method11.png]]&lt;br /&gt;
&lt;br /&gt;
Following methods were extracted from '''assignment_form_save_handler''':&lt;br /&gt;
* '''fix_assignment_missing_path''' - to handle non existent directory path&lt;br /&gt;
* '''update_assignment_form''' - to update assignment due dates, and questionnaire array in assignment form&lt;br /&gt;
&lt;br /&gt;
[[File:Create helper m1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Copy method.png]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
[[File:Copy helper.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list11.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
&lt;br /&gt;
[[File:Update_feedback_assignment_form_attr1.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Additional Changes==&lt;br /&gt;
You may have noticed method names have been changed. This was done to clarify what the methods do, as there were no comments to explain the methods, and shorten the names.&lt;br /&gt;
Methods have also been given comments to describe their functionality.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
'''Additional testing occurs in assignment_creation_spec, but that tests the integration of the assignments controller with other features. These may fail , but changes in the assignments_controller may not be the cause. Our build fails, but the fix is proposed [https://github.com/expertiza/expertiza/pull/1686/files# in another team's pull request, as they picked up where other developers left off for that code.]'''&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
To test our changes, follow [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/editlink these instructions] to set up the expertiza environment. If our repository produces errors during setup, verify if the issue is our repository or your setup by trying to setup the main expertiza repository.&lt;br /&gt;
&lt;br /&gt;
'''In a terminal do the following:'''&lt;br /&gt;
&lt;br /&gt;
* navigate to the experiza folder&lt;br /&gt;
* enter: rspec /app/controllers/assignments_controller&lt;br /&gt;
** for RSpec tests&lt;br /&gt;
* enter: rubocop /app/controllers/assignments_controller&lt;br /&gt;
** for Rubocop tests&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the tests passed with our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller1.png|20px*20px]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
As can be seen from [https://coveralls.io/jobs/60782737 Coverall], our changes have increased the coverage of assignments_controller.rb by 10.9%, from 30.5% up to 41.41%. While we did not make any changes to the tests, we did reduce the amount of testable code by reducing redundancy and extracting common code in the controller.&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
* More thorough tests can be added to the assignments_controller spec to get the coverage closer to 100%.&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132590</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132590"/>
		<updated>2020-04-01T01:33:26Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. This controller is responsible for creating and changing assignments. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''assignment_form_save_handler''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method from 33 to 15. Assignment Branch Condition size was also reduced from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create method11.png]]&lt;br /&gt;
&lt;br /&gt;
Following methods were extracted from '''assignment_form_save_handler''':&lt;br /&gt;
* '''fix_assignment_missing_path''' - to handle non existent directory path&lt;br /&gt;
* '''update_assignment_form''' - to update assignment due dates, and questionnaire array in assignment form&lt;br /&gt;
&lt;br /&gt;
[[File:Create helper m1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Copy method.png]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
[[File:Copy helper.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list11.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
&lt;br /&gt;
[[File:Update_feedback_assignment_form_attr1.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Additional Changes==&lt;br /&gt;
You may have noticed method names have been changed. This was done to clarify what the methods do, as there were no comments to explain the methods, and shorten the names.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
'''Additional testing occurs in assignment_creation_spec, but that tests the integration of the assignments controller with other features. These may fail , but changes in the assignments_controller may not be the cause. Our build fails, but the fix is proposed [https://github.com/expertiza/expertiza/pull/1686/files# in another team's pull request, as they picked up where other developers left off for that code.]'''&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
To test our changes, follow [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/editlink these instructions] to set up the expertiza environment. If our repository produces errors during setup, verify if the issue is our repository or your setup by trying to setup the main expertiza repository.&lt;br /&gt;
&lt;br /&gt;
'''In a terminal do the following:'''&lt;br /&gt;
&lt;br /&gt;
* navigate to the experiza folder&lt;br /&gt;
* enter: rspec /app/controllers/assignments_controller&lt;br /&gt;
** for RSpec tests&lt;br /&gt;
* enter: rubocop /app/controllers/assignments_controller&lt;br /&gt;
** for Rubocop tests&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the tests passed with our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
As can be seen from [https://coveralls.io/jobs/60782737 Coverall], our changes have increased the coverage of assignments_controller.rb by 10.9%, from 30.5% up to 41.41%. While we did not make any changes to the tests, we did reduce the amount of testable code by reducing redundancy and extracting common code in the controller.&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
* More thorough tests can be added to the assignments_controller spec to get the coverage closer to 100%.&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132587</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132587"/>
		<updated>2020-04-01T01:30:39Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Background */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. This controller is responsible for creating and changing assignments. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''assignment_form_save_handler''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method from 33 to 15. Assignment Branch Condition size was also reduced from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create method11.png]]&lt;br /&gt;
&lt;br /&gt;
Following methods were extracted from '''assignment_form_save_handler''':&lt;br /&gt;
* '''fix_assignment_missing_path''' - to handle non existent directory path&lt;br /&gt;
* '''update_assignment_form''' - to update assignment due dates, and questionnaire array in assignment form&lt;br /&gt;
&lt;br /&gt;
[[File:Create helper m1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Copy method.png]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
[[File:Copy helper.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list11.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
&lt;br /&gt;
[[File:Update_feedback_assignment_form_attr1.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
'''Additional testing occurs in assignment_creation_spec, but that tests the integration of the assignments controller with other features. These may fail , but changes in the assignments_controller may not be the cause. Our build fails, but the fix is proposed [https://github.com/expertiza/expertiza/pull/1686/files# in another team's pull request, as they picked up where other developers left off for that code.]'''&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
To test our changes, follow [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/editlink these instructions] to set up the expertiza environment. If our repository produces errors during setup, verify if the issue is our repository or your setup by trying to setup the main expertiza repository.&lt;br /&gt;
&lt;br /&gt;
'''In a terminal do the following:'''&lt;br /&gt;
&lt;br /&gt;
* navigate to the experiza folder&lt;br /&gt;
* enter: rspec /app/controllers/assignments_controller&lt;br /&gt;
** for RSpec tests&lt;br /&gt;
* enter: rubocop /app/controllers/assignments_controller&lt;br /&gt;
** for Rubocop tests&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the tests passed with our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
As can be seen from [https://coveralls.io/jobs/60782737 Coverall], our changes have increased the coverage of assignments_controller.rb by 10.9%, from 30.5% up to 41.41%. While we did not make any changes to the tests, we did reduce the amount of testable code by reducing redundancy and extracting common code in the controller.&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
* More thorough tests can be added to the assignments_controller spec to get the coverage closer to 100%.&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132585</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132585"/>
		<updated>2020-04-01T01:27:37Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* The branch condition size for edit method is too high */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''assignment_form_save_handler''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method from 33 to 15. Assignment Branch Condition size was also reduced from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create method11.png]]&lt;br /&gt;
&lt;br /&gt;
Following methods were extracted from '''assignment_form_save_handler''':&lt;br /&gt;
* '''fix_assignment_missing_path''' - to handle non existent directory path&lt;br /&gt;
* '''update_assignment_form''' - to update assignment due dates, and questionnaire array in assignment form&lt;br /&gt;
&lt;br /&gt;
[[File:Create helper m1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Copy method.png]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
[[File:Copy helper.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list11.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
&lt;br /&gt;
[[File:Update_feedback_assignment_form_attr1.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
'''Additional testing occurs in assignment_creation_spec, but that tests the integration of the assignments controller with other features. These may fail , but changes in the assignments_controller may not be the cause. Our build fails, but the fix is proposed [https://github.com/expertiza/expertiza/pull/1686/files# in another team's pull request, as they picked up where other developers left off for that code.]'''&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
To test our changes, follow [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/editlink these instructions] to set up the expertiza environment. If our repository produces errors during setup, verify if the issue is our repository or your setup by trying to setup the main expertiza repository.&lt;br /&gt;
&lt;br /&gt;
'''In a terminal do the following:'''&lt;br /&gt;
&lt;br /&gt;
* navigate to the experiza folder&lt;br /&gt;
* enter: rspec /app/controllers/assignments_controller&lt;br /&gt;
** for RSpec tests&lt;br /&gt;
* enter: rubocop /app/controllers/assignments_controller&lt;br /&gt;
** for Rubocop tests&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the tests passed with our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
As can be seen from [https://coveralls.io/jobs/60782737 Coverall], our changes have increased the coverage of assignments_controller.rb by 10.9%, from 30.5% up to 41.41%. While we did not make any changes to the tests, we did reduce the amount of testable code by reducing redundancy and extracting common code in the controller.&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
* More thorough tests can be added to the assignments_controller spec to get the coverage closer to 100%.&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132584</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132584"/>
		<updated>2020-04-01T01:26:13Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* The branch condition size for edit method is too high */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''assignment_form_save_handler''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method from 33 to 15. Assignment Branch Condition size was also reduced from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create method11.png]]&lt;br /&gt;
&lt;br /&gt;
Following methods were extracted from '''assignment_form_save_handler''':&lt;br /&gt;
* '''fix_assignment_missing_path''' - to handle non existent directory path&lt;br /&gt;
* '''update_assignment_form''' - to update assignment due dates, and questionnaire array in assignment form&lt;br /&gt;
&lt;br /&gt;
[[File:Create helper m1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone for an assignment.&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Copy method.png]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
[[File:Copy helper.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list11.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
&lt;br /&gt;
[[File:Update_feedback_assignment_form_attr1.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
'''Additional testing occurs in assignment_creation_spec, but that tests the integration of the assignments controller with other features. These may fail , but changes in the assignments_controller may not be the cause. Our build fails, but the fix is proposed [https://github.com/expertiza/expertiza/pull/1686/files# in another team's pull request, as they picked up where other developers left off for that code.]'''&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
To test our changes, follow [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/editlink these instructions] to set up the expertiza environment. If our repository produces errors during setup, verify if the issue is our repository or your setup by trying to setup the main expertiza repository.&lt;br /&gt;
&lt;br /&gt;
'''In a terminal do the following:'''&lt;br /&gt;
&lt;br /&gt;
* navigate to the experiza folder&lt;br /&gt;
* enter: rspec /app/controllers/assignments_controller&lt;br /&gt;
** for RSpec tests&lt;br /&gt;
* enter: rubocop /app/controllers/assignments_controller&lt;br /&gt;
** for Rubocop tests&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the tests passed with our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
As can be seen from [https://coveralls.io/jobs/60782737 Coverall], our changes have increased the coverage of assignments_controller.rb by 10.9%, from 30.5% up to 41.41%. While we did not make any changes to the tests, we did reduce the amount of testable code by reducing redundancy and extracting common code in the controller.&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
* More thorough tests can be added to the assignments_controller spec to get the coverage closer to 100%.&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132580</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132580"/>
		<updated>2020-04-01T01:15:37Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* The branch condition size for edit method is too high */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''assignment_form_save_handler''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method from 33 to 15. Assignment Branch Condition size was also reduced from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create method11.png]]&lt;br /&gt;
&lt;br /&gt;
Following methods were extracted from '''assignment_form_save_handler''':&lt;br /&gt;
* '''fix_assignment_missing_path''' - to handle non existent directory path&lt;br /&gt;
* '''update_assignment_form''' - to update assignment due dates, and questionnaire array in assignment form&lt;br /&gt;
&lt;br /&gt;
[[File:Create helper m1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list11.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
&lt;br /&gt;
[[File:Update_feedback_assignment_form_attr1.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
'''Additional testing occurs in assignment_creation_spec, but that tests the integration of the assignments controller with other features. These may fail , but changes in the assignments_controller may not be the cause. Our build fails, but the fix is proposed [https://github.com/expertiza/expertiza/pull/1686/files# in another team's pull request, as they picked up where other developers left off for that code.]'''&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
To test our changes, follow [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/editlink these instructions] to set up the expertiza environment. If our repository produces errors during setup, verify if the issue is our repository or your setup by trying to setup the main expertiza repository.&lt;br /&gt;
&lt;br /&gt;
'''In a terminal do the following:'''&lt;br /&gt;
&lt;br /&gt;
* navigate to the experiza folder&lt;br /&gt;
* enter: rspec /app/controllers/assignments_controller&lt;br /&gt;
** for RSpec tests&lt;br /&gt;
* enter: rubocop /app/controllers/assignments_controller&lt;br /&gt;
** for Rubocop tests&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the tests passed with our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
As can be seen from [https://coveralls.io/jobs/60782737 Coverall], our changes have increased the coverage of assignments_controller.rb by 10.9%, from 30.5% up to 41.41%. While we did not make any changes to the tests, we did reduce the amount of testable code by reducing redundancy and extracting common code in the controller.&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
* More thorough tests can be added to the assignments_controller spec to get the coverage closer to 100%.&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132579</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132579"/>
		<updated>2020-04-01T01:14:36Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* The branch condition size for update_feedback_assignment_form_attributes method is too high */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''assignment_form_save_handler''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method from 33 to 15. Assignment Branch Condition size was also reduced from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create method11.png]]&lt;br /&gt;
&lt;br /&gt;
Following methods were extracted from '''assignment_form_save_handler''':&lt;br /&gt;
* '''fix_assignment_missing_path''' - to handle non existent directory path&lt;br /&gt;
* '''update_assignment_form''' - to update assignment due dates, and questionnaire array in assignment form&lt;br /&gt;
&lt;br /&gt;
[[File:Create helper m1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit method.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
[[File:Edit helper1.png]]&lt;br /&gt;
[[File:Edit helper2.png]]&lt;br /&gt;
[[File:Edit helper3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list11.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
&lt;br /&gt;
[[File:Update_feedback_assignment_form_attr1.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
'''Additional testing occurs in assignment_creation_spec, but that tests the integration of the assignments controller with other features. These may fail , but changes in the assignments_controller may not be the cause. Our build fails, but the fix is proposed [https://github.com/expertiza/expertiza/pull/1686/files# in another team's pull request, as they picked up where other developers left off for that code.]'''&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
To test our changes, follow [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/editlink these instructions] to set up the expertiza environment. If our repository produces errors during setup, verify if the issue is our repository or your setup by trying to setup the main expertiza repository.&lt;br /&gt;
&lt;br /&gt;
'''In a terminal do the following:'''&lt;br /&gt;
&lt;br /&gt;
* navigate to the experiza folder&lt;br /&gt;
* enter: rspec /app/controllers/assignments_controller&lt;br /&gt;
** for RSpec tests&lt;br /&gt;
* enter: rubocop /app/controllers/assignments_controller&lt;br /&gt;
** for Rubocop tests&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the tests passed with our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
===Coverage===&lt;br /&gt;
As can be seen from [https://coveralls.io/jobs/60782737 Coverall], our changes have increased the coverage of assignments_controller.rb by 10.9%, from 30.5% up to 41.41%. While we did not make any changes to the tests, we did reduce the amount of testable code by reducing redundancy and extracting common code in the controller.&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
* More thorough tests can be added to the assignments_controller spec to get the coverage closer to 100%.&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132447</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132447"/>
		<updated>2020-03-31T21:00:55Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit12.jpeg]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce branch size of edit method1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
'''Additional testing occurs in assignment_creation_spec, but that tests the integration of the assignments controller with other features. These may fail , but changes in the assignments_controller may not be the cause. Our build fails, but the fix is proposed [https://github.com/expertiza/expertiza/pull/1686/files# in another team's pull request, as they picked up where other developers left off for that code.]'''&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
To test our changes, follow [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/editlink these instructions] to set up the expertiza environment. If our repository produces errors during setup, verify if the issue is our repository or your setup by trying to setup the main expertiza repository.&lt;br /&gt;
&lt;br /&gt;
'''In a terminal do the following:'''&lt;br /&gt;
&lt;br /&gt;
* navigate to the experiza folder&lt;br /&gt;
* enter: rspec /app/controllers/assignments_controller&lt;br /&gt;
** for RSpec tests&lt;br /&gt;
* enter: rubocop /app/controllers/assignments_controller&lt;br /&gt;
** for Rubocop tests&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the tests passed with our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132281</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132281"/>
		<updated>2020-03-31T00:30:17Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit12.jpeg]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce branch size of edit method1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
Additional testing occurs in assignment_creation_spec, but that tests the integration of the assignments controller with other features. These may fail (they currently do not, but did as the result of another team making changes elsewhere), but changes in the assignments_controller may not be the cause.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
To test our changes, follow [https://docs.google.com/document/d/1tXmwju6R7KQbvycku-bdXxa6rXSUN4BMyvjY3ROmMSw/editlink these instructions] to set up the expertiza environment. If our repository produces errors during setup, verify if the issue is our repository or your setup by trying to setup the main expertiza repository.&lt;br /&gt;
&lt;br /&gt;
'''In a terminal do the following:'''&lt;br /&gt;
&lt;br /&gt;
* navigate to the experiza folder&lt;br /&gt;
* enter: rspec /app/controllers/assignments_controller&lt;br /&gt;
** for RSpec tests&lt;br /&gt;
* enter: rubocop /app/controllers/assignments_controller&lt;br /&gt;
** for Rubocop tests&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the tests passed with our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132274</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132274"/>
		<updated>2020-03-30T22:29:42Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit12.jpeg]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce branch size of edit method1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
Additional testing occurs in assignment_creation_spec, but that tests the integration of the assignments controller with other features. These may fail (they currently do not, but did as the result of another team making changes elsewhere), but changes in the assignments_controller may not be the cause.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132271</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132271"/>
		<updated>2020-03-30T22:16:09Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit12.jpeg]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce branch size of edit method1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
These tests were included and not added to because they cover all the instances that the methods would be used under. Our additions to the code, helper methods, do not have tests as they are used in the main methods and do not need their own tests. Otherwise, there would be redundant testing. The helper methods did not change any functionality.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132268</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132268"/>
		<updated>2020-03-30T22:13:57Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Future improvements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit12.jpeg]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce branch size of edit method1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
Helper methods do not have tests as the are used in the main methods. Otherwise, there would be redundant testing.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* There are other portions of the assignments_controller that can be refactored.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132267</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132267"/>
		<updated>2020-03-30T22:12:19Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit12.jpeg]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce branch size of edit method1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** ''creates a new AssignmentForm object and renders assignment#new page''&lt;br /&gt;
* '''create'''&lt;br /&gt;
** ''when assignment_form is saved successfully''&lt;br /&gt;
** ''when assignment_form is not saved'' &lt;br /&gt;
* '''edit'''&lt;br /&gt;
** ''when assignment has staggered deadlines''&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* '''update'''&lt;br /&gt;
** ''when params does not have key :assignment_form''&lt;br /&gt;
*** ''when assignment is saved successfully''&lt;br /&gt;
*** ''when assignment is not saved successfully''&lt;br /&gt;
** ''when params has key :assignment_form''&lt;br /&gt;
*** ''when the timezone preference of current user is nil and assignment form updates attributes successfully''&lt;br /&gt;
*** ''when the timezone preference of current user is not nil and assignment form updates attributes successfully''&lt;br /&gt;
* '''show'''&lt;br /&gt;
** ''renders assignments#show page''&lt;br /&gt;
* '''copy'''&lt;br /&gt;
** ''when new assignment id fetches successfully''&lt;br /&gt;
** ''when new assignment directory is same as old''&lt;br /&gt;
** ''when new assignment id does not fetch successfully''&lt;br /&gt;
* '''delete'''&lt;br /&gt;
** ''when assignment is deleted successfully''&lt;br /&gt;
** ''when assignment is not deleted successfully''&lt;br /&gt;
Helper methods do not have tests as the are used in the main methods. Otherwise, there would be redundant testing.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* The rspec features fails for assignment creation. Tests need to be redone to properly represent the code that is present or deleted.&lt;br /&gt;
* The code needs more documentation. Nearly all of the functionality in assignments_controller is undocumented and can be unclear to new developers.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132266</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132266"/>
		<updated>2020-03-30T22:05:10Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit12.jpeg]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce branch size of edit method1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* '''action_allowed?'''&lt;br /&gt;
** ''when params action is edit or update''&lt;br /&gt;
*** ''when the role name of current user is super admin or admin''&lt;br /&gt;
*** ''when current user is the instructor of current assignment''&lt;br /&gt;
*** ''when current user is the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is a ta but not the ta of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is the instructor of the course which current assignment belongs to''&lt;br /&gt;
*** ''when current user is an instructor but not the instructor of current course or current assignment''&lt;br /&gt;
** ''when params action is not edit and update''&lt;br /&gt;
** ''when the role current user is super admin/admin/instructor/ta''&lt;br /&gt;
** ''when the role current user is student''&lt;br /&gt;
* '''new'''&lt;br /&gt;
** creates a new AssignmentForm object and renders assignment#new page&lt;br /&gt;
* create&lt;br /&gt;
** when assignment_form is saved successfully&lt;br /&gt;
** when assignment_form is not saved &lt;br /&gt;
* edit&lt;br /&gt;
** when assignment has staggered deadlines&lt;br /&gt;
** As value errors should be covered in the ability to make assignments, the only test needed for this is when deadlines are staggered. A reminder for specifying rubrics is also tested.&lt;br /&gt;
* update&lt;br /&gt;
* show&lt;br /&gt;
* copy&lt;br /&gt;
* delete&lt;br /&gt;
Helper methods do not have tests as the are used in the main methods. Otherwise, there would be redundant testing.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* The rspec features fails for assignment creation. Tests need to be redone to properly represent the code that is present or deleted.&lt;br /&gt;
* The code needs more documentation. Nearly all of the functionality in assignments_controller is undocumented and can be unclear to new developers.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132265</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132265"/>
		<updated>2020-03-30T21:51:31Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit12.jpeg]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce branch size of edit method1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
RSpect tests exist for the main methods used in the assignments controller:&lt;br /&gt;
* action_allowed?&lt;br /&gt;
** when params action is edit or update&lt;br /&gt;
*** when the role name of current user is super admin or admin&lt;br /&gt;
*** when current user is the instructor of current assignment&lt;br /&gt;
*** when current user is the ta of the course which current assignment belongs to&lt;br /&gt;
*** when current user is a ta but not the ta of the course which current assignment belongs to&lt;br /&gt;
*** when current user is the instructor of the course which current assignment belongs to&lt;br /&gt;
*** when current user is an instructor but not the instructor of current course or current assignment&lt;br /&gt;
** when params action is not edit and update&lt;br /&gt;
** when the role current user is super admin/admin/instructor/ta&lt;br /&gt;
** when the role current user is student&lt;br /&gt;
* new&lt;br /&gt;
* create&lt;br /&gt;
* edit&lt;br /&gt;
* update&lt;br /&gt;
* show&lt;br /&gt;
* copy&lt;br /&gt;
* delete&lt;br /&gt;
Helper methods do not have tests as the are used in the main methods. Otherwise, there would be redundant testing.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* The rspec features fails for assignment creation. Tests need to be redone to properly represent the code that is present or deleted.&lt;br /&gt;
* The code needs more documentation. Nearly all of the functionality in assignments_controller is undocumented and can be unclear to new developers.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132262</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=132262"/>
		<updated>2020-03-30T21:39:10Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit12.jpeg]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce branch size of edit method1.jpeg]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
in progress&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
[[File:Rspec assignment controller.png]]&lt;br /&gt;
&lt;br /&gt;
We also ran rubocop for '''assignments_controller.rb''' file, and were able to eliminate the issues reported for methods we worked on.&lt;br /&gt;
[[File:Rubocop.png]]&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
* The rspec features fails for assignment creation. Tests need to be redone to properly represent the code that is present or deleted.&lt;br /&gt;
* The code needs more documentation. Nearly all of the functionality in assignments_controller is undocumented and can be unclear to new developers.&lt;br /&gt;
* There could be a collection of messages that are used in the application that can then be referenced in the code. This would have two benefits: allowing for a different message collection to be used for translations and also removing duplicate messages like are seen here:&lt;br /&gt;
  ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, &amp;quot;Assignment #{assignment_form.assignment.id} was deleted.&amp;quot;, request)&lt;br /&gt;
  flash[:success] = 'The assignment was successfully deleted.'&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131809</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131809"/>
		<updated>2020-03-23T20:05:43Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* The branch condition size for copy method is too high */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit1.JPG]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:reduce_branch_size_of_edit_method.JPG]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods '''update_copy_session''' and '''check_same_directory?'''&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
The rspec features fails for assignment creation. Tests need to be redone to properly represent the code that is present or deleted.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131808</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131808"/>
		<updated>2020-03-23T20:05:18Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* The branch condition size for edit method is too high */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit1.JPG]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:reduce_branch_size_of_edit_method.JPG]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods '''update_due_date''', '''update_assignment_badges''', '''handle_missing_assignment_details''', and '''user_timezone_specified''' were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods update_copy_session and check_same_directory?&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
The rspec features fails for assignment creation. Tests need to be redone to properly represent the code that is present or deleted.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131807</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131807"/>
		<updated>2020-03-23T20:04:11Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* Future improvements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit1.JPG]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:reduce_branch_size_of_edit_method.JPG]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods update_due_date, update_assignment_badges, handle_missing_assignment_details, and user_timezone_specified were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods update_copy_session and check_same_directory?&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
The rspec features fails for assignment creation. Tests need to be redone to properly represent the code that is present or deleted.&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131802</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131802"/>
		<updated>2020-03-23T19:59:42Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* The branch condition size for copy method is too high */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit1.JPG]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:reduce_branch_size_of_edit_method.JPG]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods update_due_date, update_assignment_badges, handle_missing_assignment_details, and user_timezone_specified were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Before reduce assignment copy branch size.JPG]]&lt;br /&gt;
&lt;br /&gt;
The branch size of the copy method was inflated due to:&lt;br /&gt;
* Assigning (old_assign and new_assign) things that are only used once or not all&lt;br /&gt;
* Calling methods to assign values only used once&lt;br /&gt;
&lt;br /&gt;
[[File:Reduce assignment copy branch size.JPG ]]&lt;br /&gt;
&lt;br /&gt;
To reduce the branch size:&lt;br /&gt;
* Group assignments into a helper method which reduces the assignment and method call count&lt;br /&gt;
&lt;br /&gt;
[[File:Assignment copy helper methods.JPG]]&lt;br /&gt;
&lt;br /&gt;
We created helper methods update_copy_session and check_same_directory?&lt;br /&gt;
* update_copy_session contains assignments unused in the copy method, but relevant to the program&lt;br /&gt;
* check_same_directory compares directories for two assignment IDs, consolidating the conditional used in the copy method.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Reduce_assignment_copy_branch_size.JPG&amp;diff=131799</id>
		<title>File:Reduce assignment copy branch size.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Reduce_assignment_copy_branch_size.JPG&amp;diff=131799"/>
		<updated>2020-03-23T19:49:11Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Assignment_copy_helper_methods.JPG&amp;diff=131798</id>
		<title>File:Assignment copy helper methods.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Assignment_copy_helper_methods.JPG&amp;diff=131798"/>
		<updated>2020-03-23T19:49:00Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Before_reduce_assignment_copy_branch_size.JPG&amp;diff=131796</id>
		<title>File:Before reduce assignment copy branch size.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Before_reduce_assignment_copy_branch_size.JPG&amp;diff=131796"/>
		<updated>2020-03-23T19:48:46Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131794</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131794"/>
		<updated>2020-03-23T19:43:40Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* The branch condition size for edit method is too high */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:Edit1.JPG]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:reduce_branch_size_of_edit_method.JPG]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods update_due_date, update_assignment_badges, handle_missing_assignment_details, and user_timezone_specified were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Edit1.JPG&amp;diff=131792</id>
		<title>File:Edit1.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Edit1.JPG&amp;diff=131792"/>
		<updated>2020-03-23T19:43:09Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Reduce_branch_size_of_edit_method.JPG&amp;diff=131791</id>
		<title>File:Reduce branch size of edit method.JPG</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Reduce_branch_size_of_edit_method.JPG&amp;diff=131791"/>
		<updated>2020-03-23T19:41:57Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131790</id>
		<title>CSC/ECE 517 Spring 2020 - E2004. Refactor assignments controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2020_-_E2004._Refactor_assignments_controller&amp;diff=131790"/>
		<updated>2020-03-23T19:39:08Z</updated>

		<summary type="html">&lt;p&gt;Dbell5: /* The branch condition size for edit method is too high */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page contains description of changes made as part of E2004, an OSS assignment for Spring 2020, CSC/ECE 517&lt;br /&gt;
&lt;br /&gt;
==Background==&lt;br /&gt;
Expertiza allows the instructors and teaching assistants to store, retrieve, edit or delete assignments for a course that they are teaching. '''assignments_controller.rb''' is one of the biggest controllers that has a lot of scope for refactoring. It consists of the CRUD operations for an assignment along with small helper functions related to the deadlines, meta-reviews, team formation and so on. The primary issues with the code in this controller are listed as tasks.&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
=== The branch condition size for create method is too high ===&lt;br /&gt;
&lt;br /&gt;
Current implementation of create method has too many assignments and multiple layers of if conditions. It also has too many lines of code. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] has identified following issues with the method:&lt;br /&gt;
    Assignment Branch Condition size for create is too high. [56.37/15]&lt;br /&gt;
    Method `create` has 33 lines of code (exceeds 25 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
We extracted a method called '''handle_assignment_form_save''' from the code to handle the case when assignment_form is saved. This allowed in reducing the number of lines in the '''create''' method. Similarly, a helper method called '''handle_assignment_form_save''' was extracted out of the code from '''handle_assignment_form_save''' to make sure each method was only doing a single task. In order to reduce too many conditional statements, we also separated out code to handle for non existent assignment directory as '''handle_assignment_directory_path_nonexist''' method.&lt;br /&gt;
&lt;br /&gt;
By doing all of this, we were able to reduce the number of lines in the '''create''' method from 33 to 14, and Assignment Branch Condition size from 56.37 to less than 15.&lt;br /&gt;
&lt;br /&gt;
[[File:Create_file1.png]]&lt;br /&gt;
[[File:Create_file2.png]]&lt;br /&gt;
[[File:Create_file3.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for edit method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
   Assignment Branch Condition size for edit is too high. [29.58/15]&lt;br /&gt;
&lt;br /&gt;
[[File:edit1.jpg]]&lt;br /&gt;
&lt;br /&gt;
This method had assignments and method calls that could be consolidated. By removing and grouping assignments and method calls into helper methods, we can still use them and reduce the branch condition size.&lt;br /&gt;
&lt;br /&gt;
[[File:edit1.jpg]]&lt;br /&gt;
&lt;br /&gt;
Thus, the methods update_due_date, update_assignment_badges, handle_missing_assignment_details, and user_timezone_specified were created.&lt;br /&gt;
&lt;br /&gt;
* update_due_date contains the loop that adjusts due dates for an assignment.&lt;br /&gt;
* update_assignment_badges updates instance variables&lt;br /&gt;
* handle_missing_assignment_details handles some incomplete assignment details&lt;br /&gt;
* user_timezone_specified flashes an error if the user did not specify a preferred time zone.&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for copy method is too high===&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate]&lt;br /&gt;
    Assignment Branch Condition size for copy is too high. [19.42/15]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the '''empty_rubrics_list''' method has many different branches of the code that could be executed. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] identified Assignment Branch Condition size to be too high.&lt;br /&gt;
    Assignment Branch Condition size for empty_rubrics_list is too high. [18.47/15]&lt;br /&gt;
These include multiple '''if/unless''' statements as well as loops that may or may not be executed. We sought to reduce this problem by breaking up the sections of the code with different branches into their own functions, reducing the branch condition size for '''empty_rubrics_list'''.&lt;br /&gt;
&lt;br /&gt;
We extracted code to remove questionnaire types from the rubric list that are already in existing assignment questionnaires into a method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
Likewise, we extracted code that conditionally removes questionnaire types from the rubric list (such as removing the teammate review questionnaire if the team only has a size of 1) into a method named '''remove_invalid_questionnaires'''.&lt;br /&gt;
&lt;br /&gt;
[[File:Empty rubrics list1.png]]&lt;br /&gt;
&lt;br /&gt;
===The branch condition size for update_feedback_assignment_form_attributes method is too high===&lt;br /&gt;
This implementation uses nested and sequential conditional statements. While it works to decide which flash message should appear, it can be simplified by removing the nested structure and using '''elsif''' statements.&lt;br /&gt;
[[File:Update_feedback_assignment_form_attributes.png]]&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of create method is too high===&lt;br /&gt;
The current implementation of the create method has a high cognitive complexity because there are nested iteration blocks. [https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] shows following issue:&lt;br /&gt;
      Method `create` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There are two '''.each''' blocks, which are used to update '''assignment_questionnaire''' and '''due_date'''. We have resolved this issue by extracting those blocks into two separate methods named '''update_assignment_questionnaire''' and '''update_assignment_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===The cognitive complexity of empty_rubrics_list method is too high===&lt;br /&gt;
&lt;br /&gt;
The current implementation of the empty_rubrics_list method has a high cognitive complexity due to there being nested iteration blocks.[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate] indicates following issue:&lt;br /&gt;
&lt;br /&gt;
   Method `empty_rubrics_list` has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.&lt;br /&gt;
&lt;br /&gt;
There is a '''.each''' block on the assignment questionnaires and there is a '''.reject''' block on the rubric list entries nested within it. We sought to solve this issue by extracting the .reject block into a separate method named '''remove_existing_questionnaire'''.&lt;br /&gt;
&lt;br /&gt;
===A line in the handle_current_user_timezonepref_nil method is too long===&lt;br /&gt;
&lt;br /&gt;
The existing code had a line length of 180 characters. &lt;br /&gt;
  Line is too long. [180/160]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/github/rubocop-github/blob/master/STYLEGUIDE.md Rubocop style guide] recommends line length to be less than 100 characters. We have used backslash (\) to split the line into two lines of 98, and 97 characters each.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
The '''assignments_controller.rb''' file has a testing file called the '''assignment_controller_sepc.rb'''. We ran rspec tests, and made sure all the existing tests passed with all our changes.&lt;br /&gt;
&lt;br /&gt;
Here is a [https://drive.google.com/file/d/1wmmk1jO_w6QKA6JfbGfm874tGIMvZ27o/view?usp=sharing link to a video] showing test results including rubocop results for '''assignments_controller.rb'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Application Link''': http://152.46.18.46:8080&lt;br /&gt;
&lt;br /&gt;
'''Username''': instructor6&lt;br /&gt;
&lt;br /&gt;
'''Password''': password&lt;br /&gt;
&lt;br /&gt;
==Future improvements==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Team Information==&lt;br /&gt;
&lt;br /&gt;
*Dave Bell (dbell5)&lt;br /&gt;
*Steven Green (stgreen)&lt;br /&gt;
*Abhishek Upadhyaya Ghimire (aupadhy3)&lt;br /&gt;
*'''Mentor:''' Anuja Kulkarni&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
[https://codeclimate.com/github/expertiza/expertiza/app/controllers/assignments_controller.rb/source#issue-c5fc0395d3a59720b512316fd0e23502 Code Climate Issues]&lt;/div&gt;</summary>
		<author><name>Dbell5</name></author>
	</entry>
</feed>