<?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=Ggarima</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=Ggarima"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Ggarima"/>
	<updated>2026-07-02T10:26:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129869</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129869"/>
		<updated>2019-12-06T00:16:32Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Files to be changed */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:OSS12.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* Author of the assignment will use this URL to create the team and do conference paper submission. If author does not have account already in expertiza, Author will be asked to create account.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and  working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. Once instructor shares the joining link with potential Authors, they can use their existing expertiza accounts or create new accounts for making a team and add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. When Author clicks on joining link, there could be two cases that author have expertiza account or author does not have expertiza account. &lt;br /&gt;
&lt;br /&gt;
*If Author already has an account he will be able to view the assignment assigned to him and a default team.&lt;br /&gt;
*If Author does not have expertiza account, he/she will be asked to put some details to create account with role as student. After account creation, Author will receive email with login ID and password. &lt;br /&gt;
&lt;br /&gt;
3. After Author logs in, he/she can navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
4. When inviting the Co-Authors, Author can give Expertiza user name of Co-Author if they already exists in expertiza or Author can invite them by giving email id of Co-Author. &lt;br /&gt;
&lt;br /&gt;
5. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. If Co-Author expertiza account already exists, when Co-Author logs in expertiza, he or she will be able to see conference assignment in homepage and team invite in &amp;quot;Your Team&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
2. If Co-Author does not exists then he/she will receive an email with login id and password and Expertiza web address on the email id, that was used by author to invite them. When Co-Author logs in with same email id or password, he/she will be able to see conference assignment in homepage and team invite in &amp;quot;Your Team&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
3. After that Co-Author can accept or reject the team invite and proceed with assignment submission. &lt;br /&gt;
&lt;br /&gt;
4. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference' in 'Assignment' table with default value 0, and value = 1 if the assignment is  'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_g.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Design_g.png&amp;diff=129868</id>
		<title>File:Design g.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Design_g.png&amp;diff=129868"/>
		<updated>2019-12-06T00:16:23Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Design_pic.png&amp;diff=129867</id>
		<title>File:Design pic.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Design_pic.png&amp;diff=129867"/>
		<updated>2019-12-06T00:15:31Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: uploaded a new version of &amp;amp;quot;File:Design pic.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129866</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129866"/>
		<updated>2019-12-06T00:13:48Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Database Changes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:OSS12.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* Author of the assignment will use this URL to create the team and do conference paper submission. If author does not have account already in expertiza, Author will be asked to create account.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and  working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. Once instructor shares the joining link with potential Authors, they can use their existing expertiza accounts or create new accounts for making a team and add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. When Author clicks on joining link, there could be two cases that author have expertiza account or author does not have expertiza account. &lt;br /&gt;
&lt;br /&gt;
*If Author already has an account he will be able to view the assignment assigned to him and a default team.&lt;br /&gt;
*If Author does not have expertiza account, he/she will be asked to put some details to create account with role as student. After account creation, Author will receive email with login ID and password. &lt;br /&gt;
&lt;br /&gt;
3. After Author logs in, he/she can navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
4. When inviting the Co-Authors, Author can give Expertiza user name of Co-Author if they already exists in expertiza or Author can invite them by giving email id of Co-Author. &lt;br /&gt;
&lt;br /&gt;
5. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. If Co-Author expertiza account already exists, when Co-Author logs in expertiza, he or she will be able to see conference assignment in homepage and team invite in &amp;quot;Your Team&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
2. If Co-Author does not exists then he/she will receive an email with login id and password and Expertiza web address on the email id, that was used by author to invite them. When Co-Author logs in with same email id or password, he/she will be able to see conference assignment in homepage and team invite in &amp;quot;Your Team&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
3. After that Co-Author can accept or reject the team invite and proceed with assignment submission. &lt;br /&gt;
&lt;br /&gt;
4. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference' in 'Assignment' table with default value 0, and value = 1 if the assignment is  'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129865</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129865"/>
		<updated>2019-12-06T00:12:58Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Changes for Conference's co-authors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:OSS12.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* Author of the assignment will use this URL to create the team and do conference paper submission. If author does not have account already in expertiza, Author will be asked to create account.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and  working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. Once instructor shares the joining link with potential Authors, they can use their existing expertiza accounts or create new accounts for making a team and add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. When Author clicks on joining link, there could be two cases that author have expertiza account or author does not have expertiza account. &lt;br /&gt;
&lt;br /&gt;
*If Author already has an account he will be able to view the assignment assigned to him and a default team.&lt;br /&gt;
*If Author does not have expertiza account, he/she will be asked to put some details to create account with role as student. After account creation, Author will receive email with login ID and password. &lt;br /&gt;
&lt;br /&gt;
3. After Author logs in, he/she can navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
4. When inviting the Co-Authors, Author can give Expertiza user name of Co-Author if they already exists in expertiza or Author can invite them by giving email id of Co-Author. &lt;br /&gt;
&lt;br /&gt;
5. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. If Co-Author expertiza account already exists, when Co-Author logs in expertiza, he or she will be able to see conference assignment in homepage and team invite in &amp;quot;Your Team&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
2. If Co-Author does not exists then he/she will receive an email with login id and password and Expertiza web address on the email id, that was used by author to invite them. When Co-Author logs in with same email id or password, he/she will be able to see conference assignment in homepage and team invite in &amp;quot;Your Team&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
3. After that Co-Author can accept or reject the team invite and proceed with assignment submission. &lt;br /&gt;
&lt;br /&gt;
4. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129864</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129864"/>
		<updated>2019-12-06T00:12:32Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Changes for Conference's co-authors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:OSS12.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* Author of the assignment will use this URL to create the team and do conference paper submission. If author does not have account already in expertiza, Author will be asked to create account.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and  working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. Once instructor shares the joining link with potential Authors, they can use their existing expertiza accounts or create new accounts for making a team and add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. When Author clicks on joining link, there could be two cases that author have expertiza account or author does not have expertiza account. &lt;br /&gt;
&lt;br /&gt;
*If Author already has an account he will be able to view the assignment assigned to him and a default team.&lt;br /&gt;
*If Author does not have expertiza account, he/she will be asked to put some details to create account with role as student. After account creation, Author will receive email with login ID and password. &lt;br /&gt;
&lt;br /&gt;
3. After Author logs in, he/she can navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
4. When inviting the Co-Authors, Author can give Expertiza user name of Co-Author if they already exists in expertiza or Author can invite them by giving email id of Co-Author. &lt;br /&gt;
&lt;br /&gt;
5. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. If Co-Author expertiza account already exists, when Co-Author logs in expertiza, he or she will be able to see conference assignment in homepage and team invite in &amp;quot;Your Team&amp;quot; section.&lt;br /&gt;
2. If Co-Author does not exists then he/she will receive an email with login id and password and Expertiza web address on the email id, that was used by author to invite them. When Co-Author logs in with same email id or password, he/she will be able to see conference assignment in homepage and team invite in &amp;quot;Your Team&amp;quot; section.&lt;br /&gt;
3. After that Co-Author can accept or reject the team invite and proceed with assignment submission. &lt;br /&gt;
4. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129863</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129863"/>
		<updated>2019-12-06T00:11:52Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Changes for Conference's authors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:OSS12.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* Author of the assignment will use this URL to create the team and do conference paper submission. If author does not have account already in expertiza, Author will be asked to create account.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and  working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. Once instructor shares the joining link with potential Authors, they can use their existing expertiza accounts or create new accounts for making a team and add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. When Author clicks on joining link, there could be two cases that author have expertiza account or author does not have expertiza account. &lt;br /&gt;
&lt;br /&gt;
*If Author already has an account he will be able to view the assignment assigned to him and a default team.&lt;br /&gt;
*If Author does not have expertiza account, he/she will be asked to put some details to create account with role as student. After account creation, Author will receive email with login ID and password. &lt;br /&gt;
&lt;br /&gt;
3. After Author logs in, he/she can navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
4. When inviting the Co-Authors, Author can give Expertiza user name of Co-Author if they already exists in expertiza or Author can invite them by giving email id of Co-Author. &lt;br /&gt;
&lt;br /&gt;
5. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129862</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129862"/>
		<updated>2019-12-06T00:09:57Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Changes for Conference's authors */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:OSS12.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* Author of the assignment will use this URL to create the team and do conference paper submission. If author does not have account already in expertiza, Author will be asked to create account.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and  working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. Once instructor shares the joining link with potential Authors, they can use their existing expertiza accounts or create new accounts for making a team and add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. When Author clicks on joining link, there could be two cases that author have expertiza account or author does not have expertiza account. &lt;br /&gt;
&lt;br /&gt;
*If Author already has an account he will be able to view the assignment assigned to him and a default team.&lt;br /&gt;
*If Author does not have expertiza account, he/she will be asked to put some details to create account with role as student. After account creation, Author will receive email with login ID and password. &lt;br /&gt;
&lt;br /&gt;
3. After Author logs in, he/she can navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
4. When inviting the Co-Authors, Author can give Expertiza user name of Co-Author if they already exists in expertiza or Author can invite them by giving email id of Co-Author. &lt;br /&gt;
&lt;br /&gt;
* If Co-Author expertiza account already exists, when Co-Author logs in expertiza, he or she will be able to see conference assignment in homepage and team invite in &amp;quot;Your Team&amp;quot; section.&lt;br /&gt;
* If Co-Author does not exists then he/she will receive an email with login id and password and Expertiza web address on the email id, that was used by author to invite them. When Co-Author logs in with same email id or password, he/she will be able to see conference assignment in homepage and team invite in &amp;quot;Your Team&amp;quot; section.&lt;br /&gt;
* After that Co-Author can accept or reject the team invite and proceed with assignment submission. &lt;br /&gt;
&lt;br /&gt;
5. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129861</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129861"/>
		<updated>2019-12-05T23:45:02Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Creating The conference type assignment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:OSS12.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* Author of the assignment will use this URL to create the team and do conference paper submission. If author does not have account already in expertiza, Author will be asked to create account.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and  working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. After instructor has created new assignment and a team for this assignment, instructor will be able to see a URL which will be shared by him with potential authors so that they can use their existing expertiza accounts or create new accounts to add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. If Author already has an account he will be able to view the conference type assignment and his default team. If Author account does not exists he will be redirect to page '''/users/request_new?role=Student'''.  On this page author can input all the required details to create author account with role as student. This account will not require any approval from instructor to activation.&lt;br /&gt;
&lt;br /&gt;
3. After Author account is created, the author can add co-authors to this assignments.&lt;br /&gt;
&lt;br /&gt;
4. Author can login in and navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
5. Adding co-authors has following two cases - either the co-author's expertiza account already exists or a new user will be created otherwise in a similar way in which the author's account is created.&lt;br /&gt;
&lt;br /&gt;
6. Author can provide email id of co-authors in invite list of “Your Team” and will be able to view a shareable URL on page '''student_teams/view?student_id={id}''', which will be shared by author to his team mates to join this team.&lt;br /&gt;
&lt;br /&gt;
7. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129860</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129860"/>
		<updated>2019-12-05T23:42:50Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Creating The conference type assignment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:OSS12.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* Author of the assignment will use this URL to create the team and do conference paper submission. If author does not ahve account already in expertiza, Author will be asked to create assignment. Once author log in, he can create and name the team and invite Co-Authors. &lt;br /&gt;
&lt;br /&gt;
The usage of the url and it’s working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. After instructor has created new assignment and a team for this assignment, instructor will be able to see a URL which will be shared by him with potential authors so that they can use their existing expertiza accounts or create new accounts to add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. If Author already has an account he will be able to view the conference type assignment and his default team. If Author account does not exists he will be redirect to page '''/users/request_new?role=Student'''.  On this page author can input all the required details to create author account with role as student. This account will not require any approval from instructor to activation.&lt;br /&gt;
&lt;br /&gt;
3. After Author account is created, the author can add co-authors to this assignments.&lt;br /&gt;
&lt;br /&gt;
4. Author can login in and navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
5. Adding co-authors has following two cases - either the co-author's expertiza account already exists or a new user will be created otherwise in a similar way in which the author's account is created.&lt;br /&gt;
&lt;br /&gt;
6. Author can provide email id of co-authors in invite list of “Your Team” and will be able to view a shareable URL on page '''student_teams/view?student_id={id}''', which will be shared by author to his team mates to join this team.&lt;br /&gt;
&lt;br /&gt;
7. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129859</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129859"/>
		<updated>2019-12-05T23:37:38Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Sequence Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:OSS12.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* If the student does not have an expertiza account, he/she will be asked to create an account and will not be having a need to get it authorized from the admin as only those people will be able to create an account in expertiza with whom the link is shared.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and it’s working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. After instructor has created new assignment and a team for this assignment, instructor will be able to see a URL which will be shared by him with potential authors so that they can use their existing expertiza accounts or create new accounts to add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. If Author already has an account he will be able to view the conference type assignment and his default team. If Author account does not exists he will be redirect to page '''/users/request_new?role=Student'''.  On this page author can input all the required details to create author account with role as student. This account will not require any approval from instructor to activation.&lt;br /&gt;
&lt;br /&gt;
3. After Author account is created, the author can add co-authors to this assignments.&lt;br /&gt;
&lt;br /&gt;
4. Author can login in and navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
5. Adding co-authors has following two cases - either the co-author's expertiza account already exists or a new user will be created otherwise in a similar way in which the author's account is created.&lt;br /&gt;
&lt;br /&gt;
6. Author can provide email id of co-authors in invite list of “Your Team” and will be able to view a shareable URL on page '''student_teams/view?student_id={id}''', which will be shared by author to his team mates to join this team.&lt;br /&gt;
&lt;br /&gt;
7. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129858</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129858"/>
		<updated>2019-12-05T23:37:22Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Sequence Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:oss12.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* If the student does not have an expertiza account, he/she will be asked to create an account and will not be having a need to get it authorized from the admin as only those people will be able to create an account in expertiza with whom the link is shared.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and it’s working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. After instructor has created new assignment and a team for this assignment, instructor will be able to see a URL which will be shared by him with potential authors so that they can use their existing expertiza accounts or create new accounts to add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. If Author already has an account he will be able to view the conference type assignment and his default team. If Author account does not exists he will be redirect to page '''/users/request_new?role=Student'''.  On this page author can input all the required details to create author account with role as student. This account will not require any approval from instructor to activation.&lt;br /&gt;
&lt;br /&gt;
3. After Author account is created, the author can add co-authors to this assignments.&lt;br /&gt;
&lt;br /&gt;
4. Author can login in and navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
5. Adding co-authors has following two cases - either the co-author's expertiza account already exists or a new user will be created otherwise in a similar way in which the author's account is created.&lt;br /&gt;
&lt;br /&gt;
6. Author can provide email id of co-authors in invite list of “Your Team” and will be able to view a shareable URL on page '''student_teams/view?student_id={id}''', which will be shared by author to his team mates to join this team.&lt;br /&gt;
&lt;br /&gt;
7. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:OSS12.png&amp;diff=129857</id>
		<title>File:OSS12.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:OSS12.png&amp;diff=129857"/>
		<updated>2019-12-05T23:37:10Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129856</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129856"/>
		<updated>2019-12-05T23:26:42Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Sequence Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:untitled.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* If the student does not have an expertiza account, he/she will be asked to create an account and will not be having a need to get it authorized from the admin as only those people will be able to create an account in expertiza with whom the link is shared.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and it’s working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. After instructor has created new assignment and a team for this assignment, instructor will be able to see a URL which will be shared by him with potential authors so that they can use their existing expertiza accounts or create new accounts to add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. If Author already has an account he will be able to view the conference type assignment and his default team. If Author account does not exists he will be redirect to page '''/users/request_new?role=Student'''.  On this page author can input all the required details to create author account with role as student. This account will not require any approval from instructor to activation.&lt;br /&gt;
&lt;br /&gt;
3. After Author account is created, the author can add co-authors to this assignments.&lt;br /&gt;
&lt;br /&gt;
4. Author can login in and navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
5. Adding co-authors has following two cases - either the co-author's expertiza account already exists or a new user will be created otherwise in a similar way in which the author's account is created.&lt;br /&gt;
&lt;br /&gt;
6. Author can provide email id of co-authors in invite list of “Your Team” and will be able to view a shareable URL on page '''student_teams/view?student_id={id}''', which will be shared by author to his team mates to join this team.&lt;br /&gt;
&lt;br /&gt;
7. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Untitled.png&amp;diff=129855</id>
		<title>File:Untitled.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Untitled.png&amp;diff=129855"/>
		<updated>2019-12-05T23:26:27Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: uploaded a new version of &amp;amp;quot;File:Untitled.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129854</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129854"/>
		<updated>2019-12-05T23:23:50Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Sequence Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:invites.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* If the student does not have an expertiza account, he/she will be asked to create an account and will not be having a need to get it authorized from the admin as only those people will be able to create an account in expertiza with whom the link is shared.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and it’s working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. After instructor has created new assignment and a team for this assignment, instructor will be able to see a URL which will be shared by him with potential authors so that they can use their existing expertiza accounts or create new accounts to add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. If Author already has an account he will be able to view the conference type assignment and his default team. If Author account does not exists he will be redirect to page '''/users/request_new?role=Student'''.  On this page author can input all the required details to create author account with role as student. This account will not require any approval from instructor to activation.&lt;br /&gt;
&lt;br /&gt;
3. After Author account is created, the author can add co-authors to this assignments.&lt;br /&gt;
&lt;br /&gt;
4. Author can login in and navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
5. Adding co-authors has following two cases - either the co-author's expertiza account already exists or a new user will be created otherwise in a similar way in which the author's account is created.&lt;br /&gt;
&lt;br /&gt;
6. Author can provide email id of co-authors in invite list of “Your Team” and will be able to view a shareable URL on page '''student_teams/view?student_id={id}''', which will be shared by author to his team mates to join this team.&lt;br /&gt;
&lt;br /&gt;
7. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Invites.png&amp;diff=129853</id>
		<title>File:Invites.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Invites.png&amp;diff=129853"/>
		<updated>2019-12-05T23:23:28Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129852</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129852"/>
		<updated>2019-12-05T23:22:53Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Design - The Grubby Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:Untitled.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Will this be a conference type of assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* If the student does not have an expertiza account, he/she will be asked to create an account and will not be having a need to get it authorized from the admin as only those people will be able to create an account in expertiza with whom the link is shared.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and it’s working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. After instructor has created new assignment and a team for this assignment, instructor will be able to see a URL which will be shared by him with potential authors so that they can use their existing expertiza accounts or create new accounts to add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. If Author already has an account he will be able to view the conference type assignment and his default team. If Author account does not exists he will be redirect to page '''/users/request_new?role=Student'''.  On this page author can input all the required details to create author account with role as student. This account will not require any approval from instructor to activation.&lt;br /&gt;
&lt;br /&gt;
3. After Author account is created, the author can add co-authors to this assignments.&lt;br /&gt;
&lt;br /&gt;
4. Author can login in and navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
5. Adding co-authors has following two cases - either the co-author's expertiza account already exists or a new user will be created otherwise in a similar way in which the author's account is created.&lt;br /&gt;
&lt;br /&gt;
6. Author can provide email id of co-authors in invite list of “Your Team” and will be able to view a shareable URL on page '''student_teams/view?student_id={id}''', which will be shared by author to his team mates to join this team.&lt;br /&gt;
&lt;br /&gt;
7. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129841</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129841"/>
		<updated>2019-12-05T22:24:04Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Sequence Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:Untitled.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Is conference-style assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* If the student does not have an expertiza account, he/she will be asked to create an account and will not be having a need to get it authorized from the admin as only those people will be able to create an account in expertiza with whom the link is shared.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and it’s working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. After instructor has created new assignment and a team for this assignment, instructor will be able to see a URL which will be shared by him with potential authors so that they can use their existing expertiza accounts or create new accounts to add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. If Author already has an account he will be able to view the conference type assignment and his default team. If Author account does not exists he will be redirect to page '''/users/request_new?role=Student'''.  On this page author can input all the required details to create author account with role as student. This account will not require any approval from instructor to activation.&lt;br /&gt;
&lt;br /&gt;
3. After Author account is created, the author can add co-authors to this assignments.&lt;br /&gt;
&lt;br /&gt;
4. Author can login in and navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
5. Adding co-authors has following two cases - either the co-author's expertiza account already exists or a new user will be created otherwise in a similar way in which the author's account is created.&lt;br /&gt;
&lt;br /&gt;
6. Author can provide email id of co-authors in invite list of “Your Team” and will be able to view a shareable URL on page '''student_teams/view?student_id={id}''', which will be shared by author to his team mates to join this team.&lt;br /&gt;
&lt;br /&gt;
7. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129840</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129840"/>
		<updated>2019-12-05T22:23:55Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Sequence Diagram */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:Untitled.png.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Is conference-style assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* If the student does not have an expertiza account, he/she will be asked to create an account and will not be having a need to get it authorized from the admin as only those people will be able to create an account in expertiza with whom the link is shared.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and it’s working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. After instructor has created new assignment and a team for this assignment, instructor will be able to see a URL which will be shared by him with potential authors so that they can use their existing expertiza accounts or create new accounts to add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. If Author already has an account he will be able to view the conference type assignment and his default team. If Author account does not exists he will be redirect to page '''/users/request_new?role=Student'''.  On this page author can input all the required details to create author account with role as student. This account will not require any approval from instructor to activation.&lt;br /&gt;
&lt;br /&gt;
3. After Author account is created, the author can add co-authors to this assignments.&lt;br /&gt;
&lt;br /&gt;
4. Author can login in and navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
5. Adding co-authors has following two cases - either the co-author's expertiza account already exists or a new user will be created otherwise in a similar way in which the author's account is created.&lt;br /&gt;
&lt;br /&gt;
6. Author can provide email id of co-authors in invite list of “Your Team” and will be able to view a shareable URL on page '''student_teams/view?student_id={id}''', which will be shared by author to his team mates to join this team.&lt;br /&gt;
&lt;br /&gt;
7. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Untitled.png&amp;diff=129839</id>
		<title>File:Untitled.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Untitled.png&amp;diff=129839"/>
		<updated>2019-12-05T22:22:50Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: uploaded a new version of &amp;amp;quot;File:Untitled.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129819</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=129819"/>
		<updated>2019-12-05T21:43:26Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Task to be Accomplished */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
===Existing Solution===&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to add those authors and co-authors as users in expertiza, assign them to the particular assignment.&lt;br /&gt;
&lt;br /&gt;
===Proposed Solution===&lt;br /&gt;
This project concentrates on the use of expertiza assignments as conferences/journals. Using these assignments, people can submit their papers and get reviews for the same.&lt;br /&gt;
The focus of this project will be to enable a particular conference participants to create an expertiza account and teams for conference submission by minimizing the inputs required from the application admin/instructor.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* When creating a conference type assignment, a link to join the conference will be show on the assignment page.&lt;br /&gt;
* Instructor will share the joining link with Author and they should be able to create account using that link, if account already does not exist.&lt;br /&gt;
* Author will be able to create a new team in &amp;quot;Your Team&amp;quot; section and can invite other Co-Authors to join the team.&lt;br /&gt;
* If Co-Authors already exists in expertiza, they will be able to see invite on their homepage and if they do not exist in expertiza they will receive an email with joining link on email id used by Author while inviting them.&lt;br /&gt;
* Once Co-Author sees the invite they can accept or reject it.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:SequenceDiagram.png]]&lt;br /&gt;
&lt;br /&gt;
==Design - The Grubby Details==&lt;br /&gt;
&lt;br /&gt;
===Creating The conference type assignment===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the instructor would be performing to create a conference type assignment along with the changes required:&lt;br /&gt;
&lt;br /&gt;
1. Instructor logs in with his credentials.&lt;br /&gt;
&lt;br /&gt;
2. Instructor creates an assignment by checking a new check box - “Is conference-style assignment”, to mark the assignment to be of conference type.&lt;br /&gt;
&lt;br /&gt;
* This checkbox will be introduced in the Assignment’s edit page ('''app/views/assignments/edit/_general.html''')&lt;br /&gt;
&lt;br /&gt;
3. Based on the flag, once the assignment is created, a shareable URL will be displayed on the assignments page that can be used by the Instructor to share among students/authors. They will use this URL to be automatically assigned the given assignment.&lt;br /&gt;
&lt;br /&gt;
* If the student does not have an expertiza account, he/she will be asked to create an account and will not be having a need to get it authorized from the admin as only those people will be able to create an account in expertiza with whom the link is shared.&lt;br /&gt;
&lt;br /&gt;
The usage of the url and it’s working will be discussed in the next part.&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's authors===&lt;br /&gt;
&lt;br /&gt;
Following will be the high level steps the Author would be performing to create an account:&lt;br /&gt;
&lt;br /&gt;
1. After instructor has created new assignment and a team for this assignment, instructor will be able to see a URL which will be shared by him with potential authors so that they can use their existing expertiza accounts or create new accounts to add submissions to the assignment. Creation of new account will not require approval from instructor/admin. URL will be visible on page '''/assignments/{id}/edit '''.&lt;br /&gt;
&lt;br /&gt;
2. If Author already has an account he will be able to view the conference type assignment and his default team. If Author account does not exists he will be redirect to page '''/users/request_new?role=Student'''.  On this page author can input all the required details to create author account with role as student. This account will not require any approval from instructor to activation.&lt;br /&gt;
&lt;br /&gt;
3. After Author account is created, the author can add co-authors to this assignments.&lt;br /&gt;
&lt;br /&gt;
4. Author can login in and navigate to '''assignment -&amp;gt; Your Team''' and invite co-authors into his team for working on the submission.&lt;br /&gt;
&lt;br /&gt;
5. Adding co-authors has following two cases - either the co-author's expertiza account already exists or a new user will be created otherwise in a similar way in which the author's account is created.&lt;br /&gt;
&lt;br /&gt;
6. Author can provide email id of co-authors in invite list of “Your Team” and will be able to view a shareable URL on page '''student_teams/view?student_id={id}''', which will be shared by author to his team mates to join this team.&lt;br /&gt;
&lt;br /&gt;
7. The role for both Author and Co-author is a student type because the difference in the 'conference type assignment' and a normal assignment is only in the way that users are added to it(i.e., by creating an account for themselves if they don't already have an account).&lt;br /&gt;
&lt;br /&gt;
===Changes for Conference's co-authors===&lt;br /&gt;
&lt;br /&gt;
1. When a co-author click on the URL shared by author to join his team&lt;br /&gt;
&lt;br /&gt;
* If co-author already has an account, he will be asked to login and will be able to view his team and assignment.&lt;br /&gt;
* If co-author does not exist, he will be redirected to page '''/users/request_new?role=Student'''. On this page all the details required to create a new user will be entered and a student account will be created which will not require approval from instructor for account activation.&lt;br /&gt;
&lt;br /&gt;
2. Co-author's email will be verified while creating student account to validate if co-author is same person which author intended to add on his team. This will prevent spam/fake users from joining the author's team.&lt;br /&gt;
&lt;br /&gt;
===Database Changes===&lt;br /&gt;
As part of this project, the change in the database would be addition of a new column: 'is_conference_type_assignment' in 'Assignment' table with default value 0, and value = 1 if the assignment is of 'conference' type.&lt;br /&gt;
&lt;br /&gt;
===Files to be changed===&lt;br /&gt;
[[Image:Design_pic.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Please find the below plan to test the functionality&lt;br /&gt;
&lt;br /&gt;
=== RSpec Tests ===&lt;br /&gt;
Please find below RSpec Test cases for this feature&lt;br /&gt;
&lt;br /&gt;
====Scenario 1: Creating student type user from controller by bypassing admin approval ====&lt;br /&gt;
After instructor creates a conference type assignment, author should be able to create an account and this account doesn't require approval from admin.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if author is able to to create and login into a new account without admin approval&lt;br /&gt;
&lt;br /&gt;
====Scenario 2: Author/Co-author after creating an account is able to access conference type assignment====&lt;br /&gt;
After Author has created an account, he/she should be able to access the conference type account.&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Co-author is assigned to conference type assignment and able to access it&lt;br /&gt;
*Test case to check if Author has been added to default team&lt;br /&gt;
*Test case to check if Co-author is added to Author's team&lt;br /&gt;
&lt;br /&gt;
====Scenario 3: Conference type assignment being created ====&lt;br /&gt;
Instructor should be able to create conference type assignment&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Conference type assignment has been created&lt;br /&gt;
&lt;br /&gt;
====Scenario 4: Author/Co-author should be able to see assignment if they already have an account ====&lt;br /&gt;
After Instructor creates a conference type assignment, Author/Co-author clicks on link provided to them. If they already have an account, they should see conference type assignment in their assignment page&lt;br /&gt;
&lt;br /&gt;
Files associated with this functionality:&lt;br /&gt;
#users_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
Following tests will be performed to verify whether the functionality is working as desired.&lt;br /&gt;
*Test case to check if Author/Co-author already have an account&lt;br /&gt;
*Test case to validate if  Author/Co-author can see assignment in their assignment page if they already have an account&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Github Repository for Expertiza]&lt;br /&gt;
# [http://wiki.expertiza.ncsu.edu/index.php/Documentation_on_Database_Tables Expertiza Documentation on Database Tables]&lt;br /&gt;
# [https://guides.rubyonrails.org/api_app.html Rails Guide Documentation]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128661</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128661"/>
		<updated>2019-11-11T20:19:35Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
Conference assignments are the type of assignments open for all the people. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to make those authors and co-authors as users in expertiza, assign them to the particular assignment and the upload the the paper by that team. Doing all these things are mundane.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* Instructor should be able to create new link for Authors to join the Conference Assignments&lt;br /&gt;
* Author should be able to create account by clicking on the link.   If author doesnt have an account&lt;br /&gt;
* Author should be assigned to a newly created team and should be able to create a link for co-authors to join the team. &lt;br /&gt;
* Co-Authors on clicking on link should be able to join  author's team and should be able to submit work for the assignment.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:Sequence.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128646</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128646"/>
		<updated>2019-11-11T20:04:07Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
Assignments are created in Expertiza. We can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to make those authors and co-authors as users in expertiza, assign them to the particular assignment and the upload the the paper by that team. Doing all these things are mundane.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* Instructor should be able to create new link for Authors to join the Conference Assignments&lt;br /&gt;
* Author on clicking of link participants should be able to create account if not already present.author should be able to create account by clicking on the link.   If author doesnt have an account&lt;br /&gt;
* Author should be assigned to a newly created team and should be able to create a link for co-authors to join the team. &lt;br /&gt;
* Co-Authors on clicking on link should be able to join  author's team and should be able to submit work for the assignment.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:Sequence.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128632</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128632"/>
		<updated>2019-11-11T19:18:14Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
Assignments are created in Expertiza, we can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to make those authors and co-authors as users in expertiza, assign them to the particular assignment and the upload the the paper by that team. Doing all these things are mundane.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* Instructor should be able to create new link for Authors to join the Seminar Assignments&lt;br /&gt;
* Author on clicking of link participants should be able to create account if not already present.&lt;br /&gt;
* Author should be assigned to a newly created dummy team and should be able to create a link for Co-Authors to join the team.&lt;br /&gt;
* Co-Authors on clicking on link should be able to join the team of Author's and should be able to contribute on assignment.&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:Sequence.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128631</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128631"/>
		<updated>2019-11-11T19:16:41Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
Assignments are created in Expertiza, we can assign participants to assignments they are participating in, and they can submit their work for it. In today's scenario, participants share google doc, authors and co-authors name with instructor. Then instructor has to make those authors and co-authors as users in expertiza, assign them to the particular assignment and the upload the the paper by that team. Doing all these things are mundane.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* Instructor should be able to create new link for Authors to join the Seminar Assignments&lt;br /&gt;
* Author on clicking of link should be able to create account if not already present.&lt;br /&gt;
* Author should be assigned to a newly created dummy team and should be able to create a link for Co-Authors to join the team&lt;br /&gt;
* Co-Authors on clicking on link should be able to join the team of Author's and should be able to contribute on assignment&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:Sequence.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128630</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128630"/>
		<updated>2019-11-11T19:15:45Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
Assignments are created in Expertiza, we can assign participants to assignments they are participating in, and they can submit their work for it, but that is not the scenario for now. In current scenario participants, share google doc, authors and co-authors name with instructor. Then instructor has to make those authors and co-authors as users in expertiza, assign them to the particular assignment and the upload the the paper by that team. Doing all these things are mundane.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
* Instructor should be able to create new link for Authors to join the Seminar Assignments&lt;br /&gt;
* Author on clicking of link should be able to create account if not already present.&lt;br /&gt;
* Author should be assigned to a newly created dummy team and should be able to create a link for Co-Authors to join the team&lt;br /&gt;
* Co-Authors on clicking on link should be able to join the team of Author's and should be able to contribute on assignment&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
[[File:Sequence.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128629</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128629"/>
		<updated>2019-11-11T19:15:18Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
Assignments are created in Expertiza, we can assign participants to assignments they are participating in, and they can submit their work for it, but that is not the scenario for now. In current scenario participants, share google doc, authors and co-authors name with instructor. Then instructor has to make those authors and co-authors as users in expertiza, assign them to the particular assignment and the upload the the paper by that team. Doing all these things are mundane.&lt;br /&gt;
&lt;br /&gt;
==Task to be Accomplished==&lt;br /&gt;
&lt;br /&gt;
* Instructor should be able to create new link for Authors to join the Seminar Assignments&lt;br /&gt;
* Author on clicking of link should be able to create account if not already present.&lt;br /&gt;
* Author should be assigned to a newly created dummy team and should be able to create a link for Co-Authors to join the team&lt;br /&gt;
* Co-Authors on clicking on link should be able to join the team of Author's and should be able to contribute on assignment&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
&lt;br /&gt;
[[File:Sequence.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj (bbhardw)&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128628</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128628"/>
		<updated>2019-11-11T19:14:36Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Assignments are created in Expertiza, we can assign participants to assignments they are participating in, and they can submit their work for it, but that is not the scenario for now. In current scenario participants, share google doc, authors and co-authors name with instructor. Then instructor has to make those authors and co-authors as users in expertiza, assign them to the particular assignment and the upload the the paper by that team. Doing all these things are mundane.&lt;br /&gt;
&lt;br /&gt;
===Task to be Accomplished===&lt;br /&gt;
&lt;br /&gt;
* Instructor should be able to create new link for Authors to join the Seminar Assignments&lt;br /&gt;
* Author on clicking of link should be able to create account if not already present.&lt;br /&gt;
* Author should be assigned to a newly created dummy team and should be able to create a link for Co-Authors to join the team&lt;br /&gt;
* Co-Authors on clicking on link should be able to join the team of Author's and should be able to contribute on assignment&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
&lt;br /&gt;
[[File:Sequence.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj ()&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128627</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128627"/>
		<updated>2019-11-11T19:13:30Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: /* Problem Statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
===About Expertiza ===&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Assignments are created in Expertiza, we can assign participants to assignments they are participating in, and they can submit their work for it, but that is not the scenario for now. In current scenario participants, share google doc, authors and co-authors name with instructor. Then instructor has to make those authors and co-authors as users in expertiza, assign them to the particular assignment and the upload the the paper by that team. Doing all these things are mundane.&lt;br /&gt;
&lt;br /&gt;
===Task to be Accomplished===&lt;br /&gt;
&lt;br /&gt;
* Instructor should be able to create new link for Authors to join the Seminar Assignments&lt;br /&gt;
* Author on clicking of link should be able to create account if not already present.&lt;br /&gt;
* Author should be assigned to a newly created dummy team and should be able to create a link for Co-Authors to join the team&lt;br /&gt;
* Co-Authors on clicking on link should be able to join the team of Author's and should be able to contribute on assignment&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Sequence Diagram==&lt;br /&gt;
&lt;br /&gt;
[[File:Sequence.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj ()&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128622</id>
		<title>CSC/ECE 517 Fall 2019 -E1974 Allow users to create an account and submit work to an ”assignment” Design</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-E1974_Allow_users_to_create_an_account_and_submit_work_to_an_%E2%80%9Dassignment%E2%80%9D_Design&amp;diff=128622"/>
		<updated>2019-11-11T19:02:08Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
===About Expertiza ===&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
===Problem Statement===&lt;br /&gt;
Whenever someone is attending any seminar they have to submit their paper for it. Seminar is created as assignments in Expertiza backend. In today's scenario, participants just submit a google doc and share it with instructor. Then instructor has to download the paper and add it in expertiza assignment. Not only that, instructor has to create participants who is author or co- author in expertiza. All these things are done manually, which is not a good way. &lt;br /&gt;
The following tasks is to be  accomplished in this project:&lt;br /&gt;
&lt;br /&gt;
* Instructor should be able to create new link for Authors to join the Seminar Assignments&lt;br /&gt;
* Author on clicking of link should be able to create account if not already present.&lt;br /&gt;
* Implemented feature to show number of tags entered and total number of tags in Assignment page.&lt;br /&gt;
* Implemented feature to show tagging counts dynamically when student change tagging type in score page&lt;br /&gt;
* Added RSPEC testcases for testing changes done for tagging&lt;br /&gt;
&lt;br /&gt;
===About Tagging===&lt;br /&gt;
Expertiza has a feature of peer review where other teams can provide feedback on student's work. There is also another feature of &amp;quot;Tags&amp;quot;, where a student can answer if the feedback provided were helpful or not. Tags can vary from assignment to assignment but the main motive of it is to provide information on whether the feedback provides helpful information for student's assignment. The picture below shows an example of tags. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Teammates==&lt;br /&gt;
&lt;br /&gt;
Mentor - Prof. Edward Gehringer&lt;br /&gt;
&lt;br /&gt;
* Sameer Adhikari (sadhika2)&lt;br /&gt;
* Gurman Singh (gsingh23)&lt;br /&gt;
* Garima Garima (ggarima)&lt;br /&gt;
* Bharat Bhardwaj ()&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=127147</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=127147"/>
		<updated>2019-11-05T20:05:53Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaires Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaires we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaires controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five files we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaires Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaires Controller=====&lt;br /&gt;
This file is quiz_questionnaires_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyse create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to analyse why questionnaire_id has been passed as parameter in many question so that i can refactor the code.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US8''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Parameters =====&lt;br /&gt;
&lt;br /&gt;
This change was done in Quiz_questionnaire.rb file. Questionnaire_id is the variable which has value of params[:id], this variable was passed as method parameter in many calls when calling methods of quiz questionnaire controller, but as Quiz Questionnaire is subclass of Questionnaire and the ID can be read from instance variable, we do not need to send as separate value.&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US2, we have removed create_questionnaire method and we have also removed corresponding test of that method in spec file. Rest no changes were done in spec file. We had run the tests before and after refactoring and they have passed. &lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US3 we have removed unnecessary variables, one of the variable was questionnaire_id which was just params[:id]. This variable was passed as parameter in many of quiz questionnaire methods. we have removed this variable and method calls are changed. We have changed test cases also of all the corresponding method.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Our test plan is to create or existing test cases for all the user stories we have created and run it as soon as we are completing the user story. For most of our changes we did not have to create new test cases but we have modified exiting test cases for all the functionalities that we have been modifying. We have made changes in 2 spec file and have run the test cases. &lt;br /&gt;
&lt;br /&gt;
Below is the screenshot of the result after running the test cases.&lt;br /&gt;
&lt;br /&gt;
[[File:test.jpeg]]&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
* In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult.&lt;br /&gt;
* On editing any questionnaire, they are not getting updated. Values are being hardcoded at backend and questionnaire never gets updated. Issue#1550 has been created to fix this bug.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14 Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=127146</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=127146"/>
		<updated>2019-11-05T20:00:44Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaires Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaires we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaires controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five files we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaires Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaires Controller=====&lt;br /&gt;
This file is quiz_questionnaires_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyse create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to analyse why questionnaire_id has been passed as parameter in many question so that i can refactor the code.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US8''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Parameters =====&lt;br /&gt;
&lt;br /&gt;
This change was done in Quiz_questionnaire.rb file. Questionnaire_id is the variable which has value of params[:id], this variable was passed as method parameter in many calls when calling methods of quiz questionnaire controller, but as Quiz Questionnaire is subclass of Questionnaire and the ID can be read from instance variable, we do not need to send as separate value.&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US2, we have removed create_questionnaire method and we have also removed corresponding test of that method in spec file. Rest no changes were done in spec file. We had run the tests before and after refactoring and they have passed. &lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US3 we have removed unnecessary variables, one of the variable was questionnaire_id which was just params[:id]. This variable was passed as parameter in many of quiz questionnaire methods. we have removed this variable and method calls are changed. We have changed test cases also of all the corresponding method.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Our test plan is to create or existing test cases for all the user stories we have created and run it as soon as we are completing the user story. For most of our changes we did not have to create new test cases but we have modified exiting test cases for all the functionalities that we have been modifying. We have made changes in 2 spec file and have run the test cases. &lt;br /&gt;
&lt;br /&gt;
Below is the screenshot of the result after running the test cases.&lt;br /&gt;
&lt;br /&gt;
[[File:test.jpeg]]&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
* In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
* On editing any questionnaire, they are not getting updated. Values are being hardcoded at backend and questionnaire never gets updated. Issue#1550 has been created to fix this bug.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14 Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=127003</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=127003"/>
		<updated>2019-11-03T20:38:34Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaires Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaires we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaires controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five files we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaires Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaires Controller=====&lt;br /&gt;
This file is quiz_questionnaires_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyse create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to analyse why questionnaire_id has been passed as parameter in many question so that i can refactor the code.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US8''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Parameters =====&lt;br /&gt;
&lt;br /&gt;
This change was done in Quiz_questionnaire.rb file. Questionnaire_id is the variable which has value of params[:id], this variable was passed as method parameter in many calls when call quiz questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US2, we have removed create_questionnaire method and we have also removed corresponding test of that method in spec file. Rest no changes were done in spec file. We had run the tests before and after refactoring and they have passed. &lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US3 we have removed unnecessary variables, one of the variable was questionnaire_id which was just params[:id]. This variable was passed as parameter in many of quiz questionnaire methods. we have removed this variable and method calls are changed. We have changed test cases also of all the corresponding method.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Our test plan is to create or existing test cases for all the user stories we have created and run it as soon as we are completing the user story. For most of our changes we did not have to create new test cases but we have modified exiting test cases for all the functionalities that we have been modifying. We have made changes in 2 spec file and have run the test cases. &lt;br /&gt;
&lt;br /&gt;
Below is the screenshot of the result after running the test cases.&lt;br /&gt;
&lt;br /&gt;
[[File:test.jpeg]]&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
* In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
* On editing any questionnaire, they are not getting updated. Values are being hardcoded at backend and questionnaire never gets updated. Issue#1550 has been created to fix this bug.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14 Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=127000</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=127000"/>
		<updated>2019-11-03T20:25:58Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five files we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyse create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to analyse why questionnaire_id has been passed as parameter in many question so that i can refactor the code.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US8''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Parameters =====&lt;br /&gt;
&lt;br /&gt;
This change was done in Quiz_questionnaire.rb file. Questionnaire_id is the variable which has value of params[:id], this variable was passed as method parameter in many calls when call quiz questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US2, we have removed create_questionnaire method and we have also removed corresponding test of that method in spec file. Rest no changes were done in spec file. We had run the tests before and after refactoring and they have passed. &lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US3 we have removed unnecessary variables, one of the variable was questionnaire_id which was just params[:id]. This variable was passed as parameter in many of quiz questionnaire methods. we have removed this variable and method calls are changed. We have changed test cases also of all the corresponding method.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Our test plan is to create or existing test cases for all the user stories we have created and run it as soon as we are completing the user story. For most of our changes we did not have to create new test cases but we have modified exiting test cases for all the functionalities that we have been modifying. We have made changes in 2 spec file and have run the test cases. &lt;br /&gt;
&lt;br /&gt;
Below is the screenshot of the result after running the test cases.&lt;br /&gt;
&lt;br /&gt;
[[File:test.jpeg]]&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
* In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
* On editing any questionnaire, they are not getting updated. Values are being hardcoded at backend and questionnaire never gets updated. Issue#1550 has been created to fix this bug.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14 Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126998</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126998"/>
		<updated>2019-11-03T20:13:16Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five file we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyse create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to analyse why questionnaire_id has been passed as parameter in many question so that i can refactor the code.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US8''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Parameters =====&lt;br /&gt;
&lt;br /&gt;
This change was done in Quiz_questionnaire.rb file. Questionnaire_id is the variable which has value of params[:id], this variable was passed as method parameter in many calls when call quiz questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US2, we have removed create_questionnaire method and we have also removed corresponding test of that method in spec file. Rest no changes were done in spec file. We had run the tests before and after refactoring and they have passed. &lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US3 we have removed unnecessary variables, one of the variable was questionnaire_id which was just params[:id]. This variable was passed as parameter in many of quiz questionnaire methods. we have removed this variable and method calls are changed. We have changed test cases also of all the corresponding method.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Our test plan is to create or existing test cases for all the user stories we have created and run it as soon as we are completing the user story. For most of our changes we did not have to create new test cases but we have modified exiting test cases for all the functionalities that we have been modifying. We have made changes in 2 spec file and have run the test cases. &lt;br /&gt;
&lt;br /&gt;
Below is the screenshot of the result after running the test cases.&lt;br /&gt;
&lt;br /&gt;
[[File:test.jpeg]]&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
* In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
* On editing any questionnaire, they are not getting updated. Values are being hardcoded at backend and questionnaire never gets updated. Issue#1550 has been created to fix this bug.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14 Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126997</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126997"/>
		<updated>2019-11-03T20:12:03Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five file we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyse create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to analyse why questionnaire_id has been passed as parameter in many question so that i can refactor the code.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US8''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Parameters =====&lt;br /&gt;
&lt;br /&gt;
This change was done in Quiz_questionnaire.rb file. Questionnaire_id is the variable which has value of params[:id], this variable was passed as method parameter in many calls when call quiz questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US2, we have removed create_questionnaire method and we have also removed corresponding test of that method in spec file. Rest no changes were done in spec file. We had run the tests before and after refactoring and they have passed. &lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US3 we have removed unnecessary variables, one of the variable was questionnaire_id which was just params[:id]. This variable was passed as parameter in many of quiz questionnaire methods. we have removed this variable and method calls are changed. We have changed test cases also of all the corresponding method.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Our test plan is to create or existing test cases for all the user stories we have created and run it as soon as we are completing the user story. For most of our changes we did not have to create new test cases but we have modified exiting test cases for all the functionalities that we have been modifying. We have made changes in 2 spec file and have run the test cases. &lt;br /&gt;
&lt;br /&gt;
Below is the screenshot of the result after running the test cases.&lt;br /&gt;
&lt;br /&gt;
[[File:test.jpeg]]&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
* In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
* On editing any questionnaire, they are not getting updated. Values are being hardcoded at backend and questionnaire never gets updated. Issue#1550 has been created to fix this bug.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14/files#diff-b41fa84d1ee0c03c4e301f977fbe453d Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126996</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126996"/>
		<updated>2019-11-03T20:10:31Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five file we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyse create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to analyse why questionnaire_id has been passed as parameter in many question so that i can refactor the code.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US8''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Parameters =====&lt;br /&gt;
&lt;br /&gt;
This change was done in Quiz_questionnaire.rb file. Questionnaire_id is the variable which has value of params[:id], this variable was passed as method parameter in many calls when call quiz questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US2, we have removed create_questionnaire method and we have also removed corresponding test of that method in spec file. Rest no changes were done in spec file. We had run the tests before and after refactoring and they have passed. &lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US3 we have removed unnecessary variables, one of the variable was questionnaire_id which was just params[:id]. This variable was passed as parameter in many of quiz questionnaire methods. we have removed this variable and method calls are changed. We have changed test cases also of all the corresponding method.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Our test plan is to create or existing test cases for all the user stories we have created and run it as soon as we are completing the user story. For most of our changes we did not have to create new test cases but we have modified exiting test cases for all the functionalities that we have been modifying. We have made changes in 2 spec file and have run the test cases. &lt;br /&gt;
&lt;br /&gt;
Below is the screenshot of the result after running the test cases.&lt;br /&gt;
&lt;br /&gt;
[[File:test.jpeg]]&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
* In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
* On editing any questionnaire, they are not getting updated. Values are being hardcoded at backend and questionnaire never gets updated. Issue#1550 has been created to fix this bug.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14/files#diff-b41fa84d1ee0c03c4e301f977fbe453d Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Test.jpeg&amp;diff=126995</id>
		<title>File:Test.jpeg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Test.jpeg&amp;diff=126995"/>
		<updated>2019-11-03T20:10:00Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126994</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126994"/>
		<updated>2019-11-03T20:02:44Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five file we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyse create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to analyse why questionnaire_id has been passed as parameter in many question so that i can refactor the code.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US8''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Parameters =====&lt;br /&gt;
&lt;br /&gt;
This change was done in Quiz_questionnaire.rb file. Questionnaire_id is the variable which has value of params[:id], this variable was passed as method parameter in many calls when call quiz questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US2, we have removed create_questionnaire method and we have also removed corresponding test of that method in spec file. Rest no changes were done in spec file. We had run the tests before and after refactoring and they have passed. &lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US3 we have removed unnecessary variables, one of the variable was questionnaire_id which was just params[:id]. This variable was passed as parameter in many of quiz questionnaire methods. we have removed this variable and method calls are changed. We have changed test cases also of all the corresponding method.&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Our test plan is to create or existing test cases for all the user stories we have created and run it as soon as we are completing the user story. For most of our changes we did not have to create new test cases but we have modified exiting test cases for all the functionalities that we have been modifying. We have made changes in 2 spec file and have run the test cases. &lt;br /&gt;
&lt;br /&gt;
Below is the screenshot of the result after running the test cases.&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
* In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
* On editing any questionnaire, they are not getting updated. Values are being hardcoded at backend and questionnaire never gets updated. Issue#1550 has been created to fix this bug.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14/files#diff-b41fa84d1ee0c03c4e301f977fbe453d Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126992</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126992"/>
		<updated>2019-11-03T19:56:08Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five file we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyse create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to analyse why questionnaire_id has been passed as parameter in many question so that i can refactor the code.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US8''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Parameters =====&lt;br /&gt;
&lt;br /&gt;
This change was done in Quiz_questionnaire.rb file. Questionnaire_id is the variable which has value of params[:id], this variable was passed as method parameter in many calls when call quiz questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US2, we have removed create_questionnaire method and we have also removed corresponding test of that method in spec file. Rest no changes were done in spec file. We had run the tests before and after refactoring and they have passed. &lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US3 we have removed unnecessary variables, one of the variable was questionnaire_id which was just params[:id]. This variable was passed as parameter in many of quiz questionnaire methods. we have removed this variable and method calls are changed. We have changed test cases also of all the corresponding method.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
Our task was refactoring the controller so we have mainly focused on to pass the tests which are already written. In the refactoring we have added the methods that are private so according the Messages sent to self should not be tested behaviour we have not added extra tests.&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
* In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
* On editing any questionnaire, they are not getting updated. Values are being hardcoded at backend and questionnaire never gets updated. Issue#1550 has been created to fix this bug.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14/files#diff-b41fa84d1ee0c03c4e301f977fbe453d Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126991</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126991"/>
		<updated>2019-11-03T19:41:17Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five file we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyse create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to analyse why questionnaire_id has been passed as parameter &lt;br /&gt;
* '''US6''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US2, we have removed create_questionnaire method and we have also removed corresponding test of that method in spec file. Rest no changes were done in spec file. We had run the tests before and after refactoring and they have passed. &lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
As mentioned in US we have removed unnecessary variables We have removed extra arguments passed in function call which are not required. To pass the test for the above changes we have removed arguments in the method call.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
Our task was refactoring the controller so we have mainly focused on to pass the tests which are already written. In the refactoring we have added the methods that are private so according the Messages sent to self should not be tested behaviour we have not added extra tests.&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14/files#diff-b41fa84d1ee0c03c4e301f977fbe453d Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126987</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126987"/>
		<updated>2019-11-03T19:30:14Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_view.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five file we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyze create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
There is an extra method in Questionnaire controller which is not being used any where in the application so we have removed that method. We need to delete the test for the same and this has been done in this file only.&lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
We have removed extra arguments passed in function call which are not required. To pass the test for the above changes we have removed arguments in the method call.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
Our task was refactoring the controller so we have mainly focused on to pass the tests which are already written. In the refactoring we have added the methods that are private so according the Messages sent to self should not be tested behaviour we have not added extra tests.&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14/files#diff-b41fa84d1ee0c03c4e301f977fbe453d Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Questionnaire_view.png&amp;diff=126986</id>
		<title>File:Questionnaire view.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Questionnaire_view.png&amp;diff=126986"/>
		<updated>2019-11-03T19:30:01Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126984</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126984"/>
		<updated>2019-11-03T19:28:32Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_2.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five file we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyze create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
There is an extra method in Questionnaire controller which is not being used any where in the application so we have removed that method. We need to delete the test for the same and this has been done in this file only.&lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
We have removed extra arguments passed in function call which are not required. To pass the test for the above changes we have removed arguments in the method call.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
Our task was refactoring the controller so we have mainly focused on to pass the tests which are already written. In the refactoring we have added the methods that are private so according the Messages sent to self should not be tested behaviour we have not added extra tests.&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14/files#diff-b41fa84d1ee0c03c4e301f977fbe453d Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Questionnaire_edit_3.png&amp;diff=126983</id>
		<title>File:Questionnaire edit 3.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Questionnaire_edit_3.png&amp;diff=126983"/>
		<updated>2019-11-03T19:28:11Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Questionnaire_edit_2.png&amp;diff=126979</id>
		<title>File:Questionnaire edit 2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Questionnaire_edit_2.png&amp;diff=126979"/>
		<updated>2019-11-03T19:24:50Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126974</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126974"/>
		<updated>2019-11-03T19:22:31Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_2.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_edit.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five file we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyze create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
There is an extra method in Questionnaire controller which is not being used any where in the application so we have removed that method. We need to delete the test for the same and this has been done in this file only.&lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
We have removed extra arguments passed in function call which are not required. To pass the test for the above changes we have removed arguments in the method call.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
Our task was refactoring the controller so we have mainly focused on to pass the tests which are already written. In the refactoring we have added the methods that are private so according the Messages sent to self should not be tested behaviour we have not added extra tests.&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14/files#diff-b41fa84d1ee0c03c4e301f977fbe453d Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Questionnaire_edit.png&amp;diff=126973</id>
		<title>File:Questionnaire edit.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Questionnaire_edit.png&amp;diff=126973"/>
		<updated>2019-11-03T19:21:59Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126971</id>
		<title>CSC/ECE 517 Fall 2019 - E1946. Refactor Questionnaire controller</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2019_-_E1946._Refactor_Questionnaire_controller&amp;diff=126971"/>
		<updated>2019-11-03T19:18:09Z</updated>

		<summary type="html">&lt;p&gt;Ggarima: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides a description of the Expertiza based OSS project. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==About Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is an open source project based on [http://rubyonrails.org/ Ruby on Rails] framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams in Expertiza to work on various projects and assignments. Students can also peer review other students' submissions. Expertiza supports submission across various document types, including the URLs and wiki pages.&lt;br /&gt;
&lt;br /&gt;
==About Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
Questionnaire is the superclass for all kinds of questionnaires and rubrics, rubrics is used for evaluating submissions and teammate contributions, and taking quizzes and surveys.  All of these are subclasses of Questionnaire. This controller is used for creating, displaying, and managing Questionnaires. Different type of questionnaire can be created in Expertiza like Review, Metareview, Teammate review, Quiz Questionnaire, Global Survey, Course Survey and many more. This Controller is widely used and malfunctions can cause many issues in different parts of the system.&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of questionnaire on expertiza. It shows all the kinds of questionnaire we can create on expertiza. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_1.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot of all the review questionnaire we have created till now. We can edit, delete and do many other operations on questionnaire.&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_2.png]]&lt;br /&gt;
&lt;br /&gt;
Below is screenshot which shows how we can edit any questionnaire. &lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire_3.png]]&lt;br /&gt;
&lt;br /&gt;
==Why Refactor Questionnaire Controller==&lt;br /&gt;
&lt;br /&gt;
In Questionnaire controller below are some of the problems which needs refactoring: &lt;br /&gt;
&lt;br /&gt;
* Renaming the methods breaking Rubys naming conventions. &lt;br /&gt;
* Refactoring the methods doing multiple tasks and breaking them in different modules.&lt;br /&gt;
* Reducing the length of methods longer than 50 lines of code.&lt;br /&gt;
* Removing the string literal values used in controller.&lt;br /&gt;
* Separating the business logic from controller and putting it in method.&lt;br /&gt;
* Remove variables behaving same as ruby's given functionality.&lt;br /&gt;
* Commenting the code properly for easy understanding.&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the five file we changed as part of refactoring&lt;br /&gt;
&lt;br /&gt;
=====Questionnaire Controller===== &lt;br /&gt;
This is the questionnaires_controller.rb which handles all the CRUD operation performed on any kind of questionnaire - review or surveys, add weightage to all questions, selecting type of questions. This controller holds the major part of work done for creating questions. Creating of questionnaire was one method which was extremely complicated and not well commented about what is going on. Multiple things were done in just one method which we broke in modules doing that specific task. This controller was holding the business logic as well, which we can move to model. Variables were created separate to get value from UI. At many places string literals were being hardcoded, which were made as constants.&lt;br /&gt;
=====Questionnaire Model=====&lt;br /&gt;
This is the questionnaire.rb model file and we have added self method in it, which will create questionnaire object for us and we will get that object in controller and process it in controller. &lt;br /&gt;
=====Questionnaire Spec=====&lt;br /&gt;
This is the questionnaire_controller_spec.rb file and we have changed this file in order to test the changes we have made in Questionnaire controller.&lt;br /&gt;
=====Quiz Questionnaire Controller=====&lt;br /&gt;
This file is quiz_questionnaire_controller.rb and was calling multiple methods of quiz questionnaire by passing questionnaire id as parameter which we have removed. &lt;br /&gt;
=====Quiz Questionnaire Spec=====&lt;br /&gt;
This is quiz_questionnaire_spec.rb was changed as we have removed questionnaire ID from methods in Quiz Questionnaire controller.&lt;br /&gt;
&lt;br /&gt;
==User Stories==&lt;br /&gt;
&lt;br /&gt;
We have used Github project board to keep track of work that needs to be refactored. Below were the user stories that we have created: &lt;br /&gt;
&lt;br /&gt;
* '''US1''' - As a developer i want to analyze create questionnaire so that i can refactor and break it into modules.&lt;br /&gt;
* '''US2''' - As a developer i want to refactor the create_questionnaire method by giving it meaningful name and improving code so that it does not conflict with ruby naming standard.&lt;br /&gt;
* '''US3''' - As a developer i want to remove questionnaire_id with params[:id] so that we can remove unnecessary variables.&lt;br /&gt;
* '''US4''' - As a developer i want to remove all hardcoded values of alternatives, min label and max label and put them in literals, so that code can be aligned to coding standards.&lt;br /&gt;
* '''US5''' - As a developer i want to analyse why Questionnaire is being checked as QuizQuestionnaire multiple times and functionality is being changed, so that we can make quiz questionnaire same as rest.&lt;br /&gt;
* '''US6''' - As a developer i want to run rspecs in Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
* '''US7''' - As a developer i want to run rspecs in Quiz Questionnaire spec to so that i can make sure the changes made are working correct.&lt;br /&gt;
&lt;br /&gt;
==Refactoring==&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Method===== &lt;br /&gt;
This method was in questionnaires_controller.rb&lt;br /&gt;
Create method was very long in Questionnaire controller and was not self explanatory, number of characters in one line is more than 80 and cant be seen in one window.&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def create&lt;br /&gt;
    if params[:questionnaire][:name].blank?&lt;br /&gt;
      flash[:error] = 'A rubric or survey must have a title.'&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'new', model: params[:questionnaire][:type], private: params[:questionnaire][:private]&lt;br /&gt;
    else&lt;br /&gt;
      questionnaire_private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire = Object.const_get(params[:questionnaire][:type]).new if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      begin&lt;br /&gt;
        @questionnaire.private = questionnaire_private&lt;br /&gt;
        @questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        @questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        @questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        @questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        @questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        # E1903 : We are not sure of other type of cases, so have added a if statement. If there are only 5 cases, remove the if statement&lt;br /&gt;
        if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
          display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        @questionnaire.display_type = display_type&lt;br /&gt;
        @questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
        @questionnaire.save&lt;br /&gt;
        # Create node&lt;br /&gt;
        tree_folder = TreeFolder.where(['name like ?', @questionnaire.display_type]).first&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: @questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
        flash[:success] = 'You have successfully created a questionnaire!'&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
      redirect_to controller: 'questionnaires', action: 'edit', id: @questionnaire.id&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
In this user story we created self method in questionnaire model which will create questionnaire object and pass it in controller. Self method was divided in to two different modules which we then called into self. &lt;br /&gt;
&lt;br /&gt;
Method create_questionnaire_node(questionnaire) - This method will create a Tree node for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # This method is used to create Treenode for newly created questionnaire&lt;br /&gt;
    def create_questionnaire_node(questionnaire)&lt;br /&gt;
      tree_folder = TreeFolder.where(['name like ?', questionnaire.display_type]).first&lt;br /&gt;
&lt;br /&gt;
      if tree_folder.present?&lt;br /&gt;
        parent = FolderNode.find_by(node_object_id: tree_folder.id)&lt;br /&gt;
        QuestionnaireNode.create(parent_id: parent.id, node_object_id: questionnaire.id, type: 'QuestionnaireNode')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Method display_type_for_questionnaire(params) - This method will tell us about display type for new questionnaire in Expertiza&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Displaying the newly created questionnaire&lt;br /&gt;
    def display_type_for_questionnaire(params)&lt;br /&gt;
      display_type = params[:questionnaire][:type].split('Questionnaire')[0]&lt;br /&gt;
&lt;br /&gt;
      if %w[AuthorFeedback CourseSurvey TeammateReview GlobalSurvey AssignmentSurvey].include?(display_type)&lt;br /&gt;
        display_type = (display_type.split /(?=[A-Z])/).join(&amp;quot;%&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      display_type&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method below will be the main method for creating the questionnaire object and will call the two method we have written above. &lt;br /&gt;
Self - Assigning all variable values from UI into questionnaire object + create_questionnaire_node(questionnaire) + display_type_for_questionnaire(params)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# This method will create a questionnaire object and will be called from controller. &lt;br /&gt;
class &amp;lt;&amp;lt; self&lt;br /&gt;
    def create_new_questionnaire_obj(params, session)&lt;br /&gt;
      # Assigning values passed from UI in params[:id] to questionnaire object&lt;br /&gt;
      if Questionnaire::QUESTIONNAIRE_TYPES.include? params[:questionnaire][:type]&lt;br /&gt;
        questionnaire = Object.const_get(params[:questionnaire][:type]).new &lt;br /&gt;
        questionnaire.private = params[:questionnaire][:private] == 'true'&lt;br /&gt;
        questionnaire.name = params[:questionnaire][:name]&lt;br /&gt;
        questionnaire.instructor_id = session[:user].id&lt;br /&gt;
        questionnaire.min_question_score = params[:questionnaire][:min_question_score]&lt;br /&gt;
        questionnaire.max_question_score = params[:questionnaire][:max_question_score]&lt;br /&gt;
        questionnaire.type = params[:questionnaire][:type]&lt;br /&gt;
        # Zhewei: Right now, the display_type in 'questionnaires' table and name in 'tree_folders' table are not consistent.&lt;br /&gt;
        # In the future, we need to write migration files to make them consistency.&lt;br /&gt;
        questionnaire.display_type = display_type_for_questionnaire(params)&lt;br /&gt;
        questionnaire.instruction_loc = Questionnaire::DEFAULT_QUESTIONNAIRE_URL&lt;br /&gt;
&lt;br /&gt;
        if questionnaire.save&lt;br /&gt;
          create_questionnaire_node(questionnaire)&lt;br /&gt;
        end&lt;br /&gt;
        # returning the questionnaire object to calling method create in controller&lt;br /&gt;
        questionnaire&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Refactor Create Questionnaire Method===== &lt;br /&gt;
&lt;br /&gt;
This method was in questionnaires_controller.rb and in this user story after deep analysis of create_questionnaire method, we found that this method has not been called anywhere so we have '''removed''' this method from the questionnaire controller. &lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Variables=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have removed unnecessary variables in questionnaires_controller.rb file. In this file methods like add_new_questions, save_all_questions, save_questions, save_new_questions, delete_questions, local variable questionnaire_id was passed as a method argument which is not actually required since this value can be fetched from class variable @questionnaire.id or from params[:id]. So, this variable was unnecessary. Below is the one of the methods named save_all_questions which was using questionnaire_id as method parameter and we refactored.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to save all questions in current questionnaire.&lt;br /&gt;
  def save_all_questions&lt;br /&gt;
    questionnaire_id = params[:id]&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif !questionnaire_id.nil?&lt;br /&gt;
      redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def save_all_questions&lt;br /&gt;
    begin&lt;br /&gt;
      if params[:save]&lt;br /&gt;
        params[:question].each_pair do |k, v|&lt;br /&gt;
          @question = Question.find(k)&lt;br /&gt;
          # example of 'v' value&lt;br /&gt;
          # {&amp;quot;seq&amp;quot;=&amp;gt;&amp;quot;1.0&amp;quot;, &amp;quot;txt&amp;quot;=&amp;gt;&amp;quot;WOW&amp;quot;, &amp;quot;weight&amp;quot;=&amp;gt;&amp;quot;1&amp;quot;, &amp;quot;size&amp;quot;=&amp;gt;&amp;quot;50,3&amp;quot;, &amp;quot;max_label&amp;quot;=&amp;gt;&amp;quot;Strong agree&amp;quot;, &amp;quot;min_label&amp;quot;=&amp;gt;&amp;quot;Not agree&amp;quot;}&lt;br /&gt;
          v.each_pair do |key, value|&lt;br /&gt;
            @question.send(key + '=', value) if @question.send(key) != value&lt;br /&gt;
          end&lt;br /&gt;
&lt;br /&gt;
          @question.save&lt;br /&gt;
          flash[:success] = 'All questions have been successfully saved!'&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    rescue StandardError&lt;br /&gt;
      flash[:error] = $ERROR_INFO&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if params[:view_advice]&lt;br /&gt;
      redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]&lt;br /&gt;
    elsif params[:id].present?&lt;br /&gt;
      redirect_to edit_questionnaire_path(params[:id])&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Hardcoded String Literals=====&lt;br /&gt;
&lt;br /&gt;
As a part of this user story we have made changes in questionnaires_controller.rb file. Few methods have values directly hardcoded in code, which does not justify good coding standard. To clean up this code we used constant variables which also clearly mention what value is being set by this variable. Refactoring was done in method like add_new_questions.&lt;br /&gt;
&lt;br /&gt;
'''Before Refactoring'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    questionnaire_id = params[:id] unless params[:id].nil?&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(questionnaire_id).questions.size&lt;br /&gt;
    ((num_of_existed_questions + 1)..(num_of_existed_questions + params[:question][:total_num].to_i)).each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(txt: '', questionnaire_id: questionnaire_id, seq: i, type: params[:question][:type], break_before: true)&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = 1&lt;br /&gt;
        question.max_label = 'Strongly agree'&lt;br /&gt;
        question.min_label = 'Strongly disagree'&lt;br /&gt;
      end&lt;br /&gt;
      question.size = '50, 3' if question.is_a? Criterion&lt;br /&gt;
      question.alternatives = '0|1|2|3|4|5' if question.is_a? Dropdown&lt;br /&gt;
      question.size = '60, 5' if question.is_a? TextArea&lt;br /&gt;
      question.size = '30' if question.is_a? TextField&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(questionnaire_id.to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''After Refactoring'''&lt;br /&gt;
&lt;br /&gt;
Constants created were: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
QUESTION_MIN_SCORE = 0&lt;br /&gt;
QUESTION_MAX_SCORE = 1&lt;br /&gt;
QUESTION_MAX_LABEL = 'Strongly agree'&lt;br /&gt;
QUESTION_MIN_LABEL = 'Strongly disagree'&lt;br /&gt;
QUESTION_CRITERION_SIZE = '50, 3'&lt;br /&gt;
DROPDOWN_SCALE = '0|1|2|3|4|5'&lt;br /&gt;
TEXT_AREA_SIZE = '60, 5'&lt;br /&gt;
TEXT_FIELD_SIZE = '30'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We refactored the above method by making the constants and using them instead of just passing literals. We have also improved the logic by using the better conditions and variables in method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # Zhewei: This method is used to add new questions when editing questionnaire.&lt;br /&gt;
  def add_new_questions&lt;br /&gt;
    num_of_existed_questions = Questionnaire.find(params[:id]).questions.size&lt;br /&gt;
    question_nums =params[:question][:total_num].to_i&lt;br /&gt;
    total_question_nums = ((num_of_existed_questions + 1)..(num_of_existed_questions + question_nums))&lt;br /&gt;
&lt;br /&gt;
    total_question_nums.each do |i|&lt;br /&gt;
      question = Object.const_get(params[:question][:type]).create(&lt;br /&gt;
          txt: '',&lt;br /&gt;
          questionnaire_id: params[:id],&lt;br /&gt;
          seq: i,&lt;br /&gt;
          type: params[:question][:type],&lt;br /&gt;
          break_before: true&lt;br /&gt;
      )&lt;br /&gt;
      if question.is_a? ScoredQuestion&lt;br /&gt;
        question.weight = MAXIMUM_QUESTION_SCORE&lt;br /&gt;
        question.min_label = QUESTION_MIN_LABEL&lt;br /&gt;
        question.max_label = QUESTION_MAX_LABEL&lt;br /&gt;
      end&lt;br /&gt;
      &lt;br /&gt;
      question.alternatives = DROPDOWN_SCALE if question.is_a? Dropdown&lt;br /&gt;
      question.size = question_size(question)&lt;br /&gt;
      begin&lt;br /&gt;
        question.save&lt;br /&gt;
      rescue StandardError&lt;br /&gt;
        flash[:error] = $ERROR_INFO&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    redirect_to edit_questionnaire_path(params[:id].to_sym)&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Remove Unnecessary Checks=====&lt;br /&gt;
&lt;br /&gt;
In few methods like save_questions checks like “@questionnaire.id if !@questionnaire.id.nil? and @questionnaire.id &amp;gt; 0” are added. These kind of checks are unnecessary because since value of questionnaire.id will be present is @questionnaire class variable. To clear up such code we have removed unnecessary check. &lt;br /&gt;
&lt;br /&gt;
=====Update Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
There is an extra method in Questionnaire controller which is not being used any where in the application so we have removed that method. We need to delete the test for the same and this has been done in this file only.&lt;br /&gt;
&lt;br /&gt;
=====Update Quiz Questionnaire Spec=====&lt;br /&gt;
&lt;br /&gt;
We have removed extra arguments passed in function call which are not required. To pass the test for the above changes we have removed arguments in the method call.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
Our task was refactoring the controller so we have mainly focused on to pass the tests which are already written. In the refactoring we have added the methods that are private so according the Messages sent to self should not be tested behaviour we have not added extra tests.&lt;br /&gt;
&lt;br /&gt;
==LoopHoles== &lt;br /&gt;
&lt;br /&gt;
In several places begin and rescue statement are used without properly understanding the functionality. Due to this critical error messages are lost and debugging those error would be difficult. To fix this proper error log is added and begin rescue is removed.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
Prof. Edward Gehringer&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Garima Garima, Ggarima&lt;br /&gt;
* Bharat Bhardwaj, Bbhardw&lt;br /&gt;
* Piyush Tiwari, Ptiwari&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/pull/14/files#diff-b41fa84d1ee0c03c4e301f977fbe453d Pull Request to Merge]&lt;br /&gt;
#[http://152.7.98.234:8080/ Deployed Changes Userid - instructor6 and Password - password]&lt;br /&gt;
#[https://github.com/piyushtiw/expertiza/projects/2 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Ggarima</name></author>
	</entry>
</feed>