<?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=Mmsatar2</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=Mmsatar2"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Mmsatar2"/>
	<updated>2026-06-09T03:55:33Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A3_Upgrade_review_input_UI_and_sanitize_text_input&amp;diff=114060</id>
		<title>CSC/ECE 517 Fall 2017/E17A3 Upgrade review input UI and sanitize text input</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A3_Upgrade_review_input_UI_and_sanitize_text_input&amp;diff=114060"/>
		<updated>2017-12-01T20:02:46Z</updated>

		<summary type="html">&lt;p&gt;Mmsatar2: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
====About Expertiza====&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source project developed by North Carolina State University using Ruby on Rails. It is mainly a tool used to collaborate among students and faculty on a course and act as a common repository to track students’ progress on assignments. It is a simple tool where the instructor creates multiple assignments required and teams are assigned projects. Students submit their work and review other’s work and provide feedback.&lt;br /&gt;
&lt;br /&gt;
Wiki link:&lt;br /&gt;
http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation&lt;br /&gt;
&lt;br /&gt;
Github link:&lt;br /&gt;
https://github.com/expertiza/expertiza&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
1. The current Expertiza UI for reviewing uses a simple html text area for each criterion, which starting to look dull for the users. We would like you to improve the feel and look UI for the reviewers by applying CSS styling and arrange the layout of the questions/controls as the instructor designed in rubric designer (the rubric designer is currently being built by Michael Moran please contact him to get the specification of the data model).&lt;br /&gt;
&lt;br /&gt;
2. Moreover, the current form still uses plain old HTML form that sent the text entered in several text areas to the controller only after the user clicks the submit button. The problem with this approach is that the reviewers sometimes lose their reviews when the page is accidentally refreshed, or when a session is broken because they take too much time writing the reviews. &lt;br /&gt;
&lt;br /&gt;
3. Another problem is that the reviewers might enter their reviews from a browser with a different encoding than UTF-8. This prevents Expertiza to store the data since the database is only set up to store UTF-8 strings. Moreover, we found that the review text contains misspelled words and incorrect use of English grammar that makes the review hard to understand.  &lt;br /&gt;
&lt;br /&gt;
Updates in requirements as of 11 November, 2017&lt;br /&gt;
&lt;br /&gt;
4.Replace the text area with a rich text editor that allows user to customize the fonts, bold, insert link to images / videos (possibly generate a thumbnails of the links).&lt;br /&gt;
&lt;br /&gt;
====Possible Extension====&lt;br /&gt;
&lt;br /&gt;
1. Apply CSS styling and arrange the layout of the questions/controls in view/response/response.html.erb as the instructor designed in rubric designer.&lt;br /&gt;
&lt;br /&gt;
'''Approach:''' Our approach is still to keep the form simple but more responsive using bootstrap. Current form layout is a plain HTML layout and breaks when accessed through different types of devices but the desktop. The new layout will give the user a better user experience while submitting reviews through desktop, mobile or tablet. Please refer to wireframes section to view the changes in the layout of the review form.&lt;br /&gt;
To achieve this we will be using bootstrap 3 gems, compatible with rails 4.2.&lt;br /&gt;
&lt;br /&gt;
2. Automatically save the draft versions of all inputs and restore users draft and resume their reviewing when they accidentally close or refresh the current page.&lt;br /&gt;
&lt;br /&gt;
'''Approach:''' &lt;br /&gt;
The current design of the system clears all the data in the text fields once a session for user has been ended. We were briefed to change this design so that someone who was halfway through a review could complete it at a later time even if they ended the current browser session without saving manually. &lt;br /&gt;
&lt;br /&gt;
We are making an AJAX call to save user entered text from the current text box as soon as user switches to next text box. &lt;br /&gt;
&lt;br /&gt;
3. Checking the text content.&lt;br /&gt;
&lt;br /&gt;
'''UTF-8''' :To solve UTF-8 encoding problem, we can make a form accept only UTF-8 characters by using an attribute of the form tag. But most of the characters, including a lot of characters from languages other than English, are present in UTF-8 character set so the application will work perfectly fine on just allowing UTF-8 characters in the text box. Below is the code snippet on the same. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;form action=&amp;quot;/action&amp;quot; accept-charset=&amp;quot;UTF-8&amp;quot;&amp;gt; &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Spellcheck :'''Since we have used rich text format, spellcheck is being handled by the same and we have just enabled the spellcheck option for the browser.&lt;br /&gt;
&lt;br /&gt;
==Wireframes==&lt;br /&gt;
Our approach is still to keep the form simple but more responsive using bootstrap.This will give the user a better user experience while submitting reviews through desktop, mobile or tablet. Below is the design of our planned UI.&lt;br /&gt;
&lt;br /&gt;
'''''1. Review form layout with select and text area.'''''&lt;br /&gt;
[[File:Review1.png]]&lt;br /&gt;
&lt;br /&gt;
'''''2. Review form layout with checkboxes.'''''&lt;br /&gt;
&lt;br /&gt;
[[File:Review2.png]]&lt;br /&gt;
&lt;br /&gt;
'''''3. Review form layout with buttons and input.'''''&lt;br /&gt;
&lt;br /&gt;
[[File:Review3.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
&lt;br /&gt;
Test Cases planned to be implemented: &lt;br /&gt;
&lt;br /&gt;
1. Field Widths – If the screen contains text boxes that allow data entry and the width of data entered does not exceed the width of the form.&lt;br /&gt;
&lt;br /&gt;
2. Save and Submit Review – If the screen has the save and submit review buttons.&lt;br /&gt;
&lt;br /&gt;
3. Cosmetic Inconsistencies – The screen look, feel and design should match the other screens in your application. &lt;br /&gt;
&lt;br /&gt;
4. Grammar and Spelling – Ensure that you have test cases that look for grammar or spelling errors.&lt;br /&gt;
&lt;br /&gt;
5. Error Messages – Ensure that error messages are informative, grammatically correct, and not condescending.&lt;br /&gt;
&lt;br /&gt;
6. Screen Font Type - Ensure that the screen font family matches from screen to screen.&lt;br /&gt;
 &lt;br /&gt;
7. Backlink - Ensure that backlink is present on the screen.&lt;br /&gt;
&lt;br /&gt;
8. Review draft is saved - Ensure that user draft version is saved automatically in every 30 seconds.&lt;/div&gt;</summary>
		<author><name>Mmsatar2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A3_Upgrade_review_input_UI_and_sanitize_text_input&amp;diff=114058</id>
		<title>CSC/ECE 517 Fall 2017/E17A3 Upgrade review input UI and sanitize text input</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A3_Upgrade_review_input_UI_and_sanitize_text_input&amp;diff=114058"/>
		<updated>2017-12-01T19:45:04Z</updated>

		<summary type="html">&lt;p&gt;Mmsatar2: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
====About Expertiza====&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source project developed by North Carolina State University using Ruby on Rails. It is mainly a tool used to collaborate among students and faculty on a course and act as a common repository to track students’ progress on assignments. It is a simple tool where the instructor creates multiple assignments required and teams are assigned projects. Students submit their work and review other’s work and provide feedback.&lt;br /&gt;
&lt;br /&gt;
Wiki link:&lt;br /&gt;
http://wiki.expertiza.ncsu.edu/index.php/Expertiza_documentation&lt;br /&gt;
&lt;br /&gt;
Github link:&lt;br /&gt;
https://github.com/expertiza/expertiza&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
1. The current Expertiza UI for reviewing uses a simple html text area for each criterion, which starting to look dull for the users. We would like you to improve the feel and look UI for the reviewers by applying CSS styling and arrange the layout of the questions/controls as the instructor designed in rubric designer (the rubric designer is currently being built by Michael Moran please contact him to get the specification of the data model).&lt;br /&gt;
&lt;br /&gt;
2. Moreover, the current form still uses plain old HTML form that sent the text entered in several text areas to the controller only after the user clicks the submit button. The problem with this approach is that the reviewers sometimes lose their reviews when the page is accidentally refreshed, or when a session is broken because they take too much time writing the reviews. &lt;br /&gt;
&lt;br /&gt;
3. Another problem is that the reviewers might enter their reviews from a browser with a different encoding than UTF-8. This prevents Expertiza to store the data since the database is only set up to store UTF-8 strings. Moreover, we found that the review text contains misspelled words and incorrect use of English grammar that makes the review hard to understand.  &lt;br /&gt;
&lt;br /&gt;
Updates in requirements as of 11 November, 2017&lt;br /&gt;
&lt;br /&gt;
4.Replace the text area with a rich text editor that allows user to customize the fonts, bold, insert link to images / videos (possibly generate a thumbnails of the links).&lt;br /&gt;
&lt;br /&gt;
====Possible Extension====&lt;br /&gt;
&lt;br /&gt;
1. Apply CSS styling and arrange the layout of the questions/controls in view/response/response.html.erb as the instructor designed in rubric designer.&lt;br /&gt;
&lt;br /&gt;
'''Approach:''' Our approach is still to keep the form simple but more responsive using bootstrap. Current form layout is a plain HTML layout and breaks when accessed through different types of devices but the desktop. The new layout will give the user a better user experience while submitting reviews through desktop, mobile or tablet. Please refer to wireframes section to view the changes in the layout of the review form.&lt;br /&gt;
To achieve this we will be using bootstrap 3 gems, compatible with rails 4.2.&lt;br /&gt;
&lt;br /&gt;
2. Automatically save the draft versions of all inputs and restore users draft and resume their reviewing when they accidentally close or refresh the current page.&lt;br /&gt;
&lt;br /&gt;
'''Approach:''' &lt;br /&gt;
The current design of the system clears all the data in the text fields once a session for user has been ended. We were briefed to change this design so that someone who was halfway through a review could complete it at a later time even if they ended the current browser session without saving manually. &lt;br /&gt;
&lt;br /&gt;
We are making an AJAX call to save user entered text from the current text box as soon as user switches to next text box. &lt;br /&gt;
&lt;br /&gt;
3. Checking the text content.&lt;br /&gt;
&lt;br /&gt;
'''UTF-8''' :To solve UTF-8 encoding problem, we can make a form accept only UTF-8 characters by using an attribute of the form tag. But most of the characters, including a lot of characters from languages other than English, are present in UTF-8 character set so the application will work perfectly fine on just allowing UTF-8 characters in the text box. Below is the code snippet on the same. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;form action=&amp;quot;/action&amp;quot; accept-charset=&amp;quot;UTF-8&amp;quot;&amp;gt; &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Spellcheck :'''Since we have used rich text format, spellcheck is being handled by the same and we have just enabled the spellcheck option for the browser.&lt;br /&gt;
&lt;br /&gt;
==Wireframes==&lt;br /&gt;
Our approach is still to keep the form simple but more responsive using bootstrap.This will give the user a better user experience while submitting reviews through desktop, mobile or tablet. Below is the design of our planned UI.&lt;br /&gt;
&lt;br /&gt;
'''''1. Review form layout with select and text area.'''''&lt;br /&gt;
[[File:Review1.png]]&lt;br /&gt;
&lt;br /&gt;
'''''2. Review form layout with checkboxes.'''''&lt;br /&gt;
&lt;br /&gt;
[[File:Review2.png]]&lt;br /&gt;
&lt;br /&gt;
'''''3. Review form layout with buttons and input.'''''&lt;br /&gt;
&lt;br /&gt;
[[File:Review3.png]]&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;/div&gt;</summary>
		<author><name>Mmsatar2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A3_Upgrade_review_input_UI_and_sanitize_text_input&amp;diff=112643</id>
		<title>CSC/ECE 517 Fall 2017/E17A3 Upgrade review input UI and sanitize text input</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E17A3_Upgrade_review_input_UI_and_sanitize_text_input&amp;diff=112643"/>
		<updated>2017-11-08T04:04:25Z</updated>

		<summary type="html">&lt;p&gt;Mmsatar2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
====Description of project====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
&lt;br /&gt;
1. The current Expertiza UI for reviewing uses a simple html text area for each criterion, which starting to look dull for the users. We would like you to improve the feel and look UI for the reviewers by applying CSS styling and arrange the layout of the questions/controls as the instructor designed in rubric designer (the rubric designer is currently being built by Michael Moran please contact him to get the specification of the data model).&lt;br /&gt;
&lt;br /&gt;
2. Moreover, the current form still uses plain old HTML form that sent the text entered in several text areas to the controller only after the user clicks the submit button. The problem with this approach is that the reviewers sometimes lose their reviews when the page is accidentally refreshed, or when a session is broken because they take too much time writing the reviews. &lt;br /&gt;
&lt;br /&gt;
3. Another problem is that the reviewers might enter their reviews from a browser with a different encoding than UTF-8. This prevents Expertiza to store the data since the database is only set up to store UTF-8 strings. Moreover, we found that the review text contains misspelled words and incorrect use of English grammar that makes the review hard to understand.  &lt;br /&gt;
&lt;br /&gt;
====Possible Extension====&lt;br /&gt;
&lt;br /&gt;
1. Apply CSS styling and arrange the layout of the questions/controls in view/response/response.html.erb as the instructor designed in rubric designer.&lt;br /&gt;
&lt;br /&gt;
Approach:&lt;br /&gt;
&lt;br /&gt;
2. Automatically saving the draft versions of all inputs in the reviewing UI when the values are changed. &lt;br /&gt;
&lt;br /&gt;
Approach:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Restore users draft and resume their reviewing when they accidentally close or refresh the current page.&lt;br /&gt;
&lt;br /&gt;
Approach: &lt;br /&gt;
The current design of the system clears all the data in the text fields once a session for user has been ended. We were briefed to change this design, so that someone who was halfway through a review could complete it at a later time even if they ended the current browser session. &lt;br /&gt;
&lt;br /&gt;
Javascript has a functionality to save localStorage, so that each session has the data stored upto 5MB beyond end of page session. This feature has nothing to do with Rails directly, but localStorage can be dynamically kept in rails using javascript function assignment. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
localStorage.setItem(&amp;quot;company_id&amp;quot;, &amp;quot;&amp;lt;%= @company.id %&amp;gt;&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
This was the example shown to properly use this feature. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. Checking the text content.&lt;br /&gt;
&lt;br /&gt;
Approach&lt;br /&gt;
&lt;br /&gt;
==Wireframes==&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;/div&gt;</summary>
		<author><name>Mmsatar2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=112634</id>
		<title>CSC/ECE 517 Fall 2017/E1749 TFD questionnaire controller.rb refactor</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=112634"/>
		<updated>2017-11-08T03:50:06Z</updated>

		<summary type="html">&lt;p&gt;Mmsatar2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About ==&lt;br /&gt;
Expertiza is a website that is used and developed by NCSU students and faculty. Coded using Ruby on Rails the source code is readily available on Github -&amp;gt; https://github.com/expertiza/expertiza. The website is used by students for organizing teams, signing up for topics, reviewing other teams and  another bunch of tasks. The faculty i.e. Instructors and TAs use this website to set new tasks, add new questions and a few other tasks.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
*Shreyas Zagade&lt;br /&gt;
*Mohit Satarkar&lt;br /&gt;
*Darshan Bhandari&lt;br /&gt;
&lt;br /&gt;
==  Setting Up The Working Environment ==&lt;br /&gt;
''One of several ways to set up the environment and the one we adopted is:-'' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Ubuntu-Expertiza image (.OVA) [Recommended]''' &amp;lt;br&amp;gt;&lt;br /&gt;
:This is the link for the image. (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing) &amp;lt;br&amp;gt;&lt;br /&gt;
:And you can install VirtualBox (free) and import this image into VirtualBox. &amp;lt;br&amp;gt;&lt;br /&gt;
'''Some machine may require you to enable virtualization and then run the following commands.'''&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd expertiza &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bash ./setup.sh &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bundle install &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;rake db:migrate &amp;lt;/pre&amp;gt;&lt;br /&gt;
*For logging in as an instructor:- &amp;lt;br&amp;gt;&lt;br /&gt;
:Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
:Password: password &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Files involved==&lt;br /&gt;
&lt;br /&gt;
# questionnaire_controller.rb &lt;br /&gt;
# questionnaire_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Issues==&lt;br /&gt;
&lt;br /&gt;
:*	questionnaires_controller.rb is a fairly complex file. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	It contains a lot of methods that are long and hard to understand, these methods need to be broken down into simpler and more specific methods that are easier to read/understand. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	Also, the few instances of code duplication that exist should be removed.&lt;br /&gt;
&lt;br /&gt;
== Tasks assigned ==&lt;br /&gt;
#	Complete pending tests in questionnaires_controller_spec.rb, and write integration tests for newly-created methods. Please finish one set of pending tests first before refactoring corresponding methods. &lt;br /&gt;
#	Refactor create method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	Split into several simpler methods and assign reasonable names &lt;br /&gt;
#*	Extract duplicated code into separate methods &lt;br /&gt;
#	Refactor update_quiz, save_choices method &lt;br /&gt;
#*	Write failing tests first. &lt;br /&gt;
#*	Use polymorphism to replace the long switch statements &lt;br /&gt;
#**	Move if conditions to corresponding subclasses (eg. MultipleChoiceCheckbox.rb, MultipleChoiceRadio.rb) with same method name &lt;br /&gt;
#**	Replace the conditional with the relevant method calls &lt;br /&gt;
#**	Remove duplicated code &lt;br /&gt;
#	Use find_by instead of dynamic method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	L68, L385, L386, L559, L560&lt;br /&gt;
&lt;br /&gt;
==  Tasks Completed  ==&lt;br /&gt;
&lt;br /&gt;
*Testing&lt;br /&gt;
*Refactoring&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Testing'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1)	Completed test cases for create &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
    describe '#create' do&lt;br /&gt;
      it 'redirects to questionnaires#edit page after create a new questionnaire'&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
:After writing test case&lt;br /&gt;
   describe '#create' do&lt;br /&gt;
    it 'redirects to questionnaires#edit page after create a new questionnaire' do&lt;br /&gt;
      tree_folder1 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder1).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder1).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      tree_folder2 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder2).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      allow(TreeFolder).to receive(:where).with([&amp;quot;name like ?&amp;quot;, &amp;quot;Review&amp;quot;]).and_return([tree_folder1, tree_folder2])&lt;br /&gt;
      folder_node2 = double('FolderNode')&lt;br /&gt;
      allow(folder_node2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(FolderNode).to receive(:find_by_node_object_id).and_return(folder_node2)&lt;br /&gt;
      user = double(&amp;quot;User&amp;quot;)&lt;br /&gt;
      allow(user).to receive(:id).and_return(1)&lt;br /&gt;
      params = {&lt;br /&gt;
        questionnaire: {&lt;br /&gt;
          private: &amp;quot;true&amp;quot;,&lt;br /&gt;
          type: &amp;quot;ReviewQuestionnaire&amp;quot;,&lt;br /&gt;
          name: &amp;quot;Random Name&amp;quot;,&lt;br /&gt;
          min_question_score: &amp;quot;0&amp;quot;,&lt;br /&gt;
          max_question_score: &amp;quot;5&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      session = {user: user}&lt;br /&gt;
      get :create, params, session&lt;br /&gt;
      expect(flash[:success]).to eq(&amp;quot;You have successfully created a questionnaire!&amp;quot;)&lt;br /&gt;
      response.should redirect_to(edit_questionnaire_path(id: 1))&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2)	Completed test cases for update_quiz &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
 &lt;br /&gt;
   describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page'&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page'&lt;br /&gt;
        # params = {&lt;br /&gt;
        #   id: 1,&lt;br /&gt;
        #   pid: 1,&lt;br /&gt;
        #   save: true,&lt;br /&gt;
        #   questionnaire: {&lt;br /&gt;
        #     name: 'test questionnaire',&lt;br /&gt;
        #     instructor_id: 6,&lt;br /&gt;
        #     private: 0,&lt;br /&gt;
        #     min_question_score: 0,&lt;br /&gt;
        #     max_question_score: 5,&lt;br /&gt;
        #     type: 'ReviewQuestionnaire',&lt;br /&gt;
        #     display_type: 'Review',&lt;br /&gt;
        #     instructor_loc: ''&lt;br /&gt;
        #   },&lt;br /&gt;
        #   question: {&lt;br /&gt;
        #     '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
        #     '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
        #     '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
        #   },&lt;br /&gt;
        #   quiz_question_choices: {&lt;br /&gt;
        #     '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
        #             {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
        #     '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
        #     '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
        #             {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
        #              '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
        #   }&lt;br /&gt;
        # }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
:After writing test case&lt;br /&gt;
&lt;br /&gt;
  describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 1,&lt;br /&gt;
          pid: 1&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 3,&lt;br /&gt;
          pid: 1,&lt;br /&gt;
          save: true,&lt;br /&gt;
          questionnaire: {&lt;br /&gt;
            name: 'test questionnaire',&lt;br /&gt;
            instructor_id: 6,&lt;br /&gt;
            private: 0,&lt;br /&gt;
            min_question_score: 0,&lt;br /&gt;
            max_question_score: 5,&lt;br /&gt;
            type: 'ReviewQuestionnaire',&lt;br /&gt;
            display_type: 'Review',&lt;br /&gt;
            instructor_loc: ''&lt;br /&gt;
          },&lt;br /&gt;
          question: {&lt;br /&gt;
            '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
            '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
            '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
          },&lt;br /&gt;
          quiz_question_choices: {&lt;br /&gt;
            '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
                    {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
            '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
            '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
                    {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
                     '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Refactoring'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Create method has been split into two methods create and save_questionnaire_create&lt;br /&gt;
&lt;br /&gt;
'''Before Modification:'''&lt;br /&gt;
  def create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    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;
      case display_type&lt;br /&gt;
      when 'AuthorFeedback'&lt;br /&gt;
        display_type = 'Author%Feedback'&lt;br /&gt;
      when 'CourseSurvey'&lt;br /&gt;
        display_type = 'Course%Survey'&lt;br /&gt;
      when 'TeammateReview'&lt;br /&gt;
        display_type = 'Teammate%Review'&lt;br /&gt;
      when 'GlobalSurvey'&lt;br /&gt;
        display_type = 'Global%Survey'&lt;br /&gt;
      when 'AssignmentSurvey'&lt;br /&gt;
        display_type = 'Assignment%Survey'&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&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;
&lt;br /&gt;
'''After Modification:'''&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    begin&lt;br /&gt;
      save_questionnaire_create&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&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;
&lt;br /&gt;
&lt;br /&gt;
  def save_questionnaire_create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    end&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;
    case display_type&lt;br /&gt;
    when 'AuthorFeedback'&lt;br /&gt;
      display_type = 'Author%Feedback'&lt;br /&gt;
    when 'CourseSurvey'&lt;br /&gt;
      display_type = 'Course%Survey'&lt;br /&gt;
    when 'TeammateReview'&lt;br /&gt;
      display_type = 'Teammate%Review'&lt;br /&gt;
    when 'GlobalSurvey'&lt;br /&gt;
      display_type = 'Global%Survey'&lt;br /&gt;
    when 'AssignmentSurvey'&lt;br /&gt;
      display_type = 'Assignment%Survey'&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;
  end&lt;br /&gt;
&lt;br /&gt;
We have also refactored the update_quiz and save_choices method, by implementing the instructions assigned to us for changing their ideology. Both of these had very long switch statements, which could be much shorter and keep optimum functionality. But the use of Polymorphism to change the way the method worked turned out to be much better. &lt;br /&gt;
&lt;br /&gt;
The use of find_by instead of dynamic use was helpful. First we needed to complete the test cases at multiple mentioned line numbers. After hat, we were able to properly employ the methods as and when they were required. &lt;br /&gt;
&lt;br /&gt;
We have displayed examples wherever appropriate, and the code we have uploaded on github is more than sufficient to enlighten about the changes that have been carried out. &lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For testing methods, we don't have to check the preconditions, as we have been assigned with refactoring the methods and testing those refactored methods properly.&lt;br /&gt;
&lt;br /&gt;
We check the file questionnaires_controller_spec.rb, and test the methods required to be refactored based on our modifications we have to carry out in the spec file for the testing methods.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Methods&lt;br /&gt;
! Contexts&lt;br /&gt;
|-&lt;br /&gt;
| view&lt;br /&gt;
| Properly checks the rendering of questionnaires &lt;br /&gt;
|-&lt;br /&gt;
| new&lt;br /&gt;
| Looks for system reaction to presence of whitespace&lt;br /&gt;
|-&lt;br /&gt;
| new&lt;br /&gt;
| Tests the system reaction to absence of whitespace&lt;br /&gt;
|-&lt;br /&gt;
| create&lt;br /&gt;
| Checks if newly created page can be edited for values.&lt;br /&gt;
|-&lt;br /&gt;
| update_quiz&lt;br /&gt;
| Checks if the content in the questionnaire is nil&lt;br /&gt;
|-&lt;br /&gt;
| update_quiz&lt;br /&gt;
| Also tests if the content in the questionnaire is not nil&lt;br /&gt;
|-&lt;br /&gt;
| copy, copy_questionnaire_details, assign_instructor_id&lt;br /&gt;
| Tested the redirection to the view page of the copied questionnaire&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Mmsatar2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111196</id>
		<title>CSC/ECE 517 Fall 2017/E1749 TFD questionnaire controller.rb refactor</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111196"/>
		<updated>2017-11-02T05:52:36Z</updated>

		<summary type="html">&lt;p&gt;Mmsatar2: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About ==&lt;br /&gt;
Expertiza is a website that is used and developed by NCSU students and faculty. Coded using Ruby on Rails the source code is readily available on Github -&amp;gt; https://github.com/expertiza/expertiza. The website is used by students for organizing teams, signing up for topics, reviewing other teams and  another bunch of tasks. The faculty i.e. Instructors and TAs use this website to set new tasks, add new questions and a few other tasks.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
*Shreyas Zagade&lt;br /&gt;
*Mohit Satarkar&lt;br /&gt;
*Darshan Bhandari&lt;br /&gt;
&lt;br /&gt;
==  Setting Up The Working Environment ==&lt;br /&gt;
''One of several ways to set up the environment and the one we adopted is:-'' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Ubuntu-Expertiza image (.OVA) [Recommended]''' &amp;lt;br&amp;gt;&lt;br /&gt;
:This is the link for the image. (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing) &amp;lt;br&amp;gt;&lt;br /&gt;
:And you can install VirtualBox (free) and import this image into VirtualBox. &amp;lt;br&amp;gt;&lt;br /&gt;
'''Some machine may require you to enable virtualization and then run the following commands.'''&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd expertiza &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bash ./setup.sh &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bundle install &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;rake db:migrate &amp;lt;/pre&amp;gt;&lt;br /&gt;
*For logging in as an instructor:- &amp;lt;br&amp;gt;&lt;br /&gt;
:Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
:Password: password &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Files involved==&lt;br /&gt;
&lt;br /&gt;
# questionnaire_controller.rb &lt;br /&gt;
# questionnaire_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Issues==&lt;br /&gt;
&lt;br /&gt;
:*	questionnaires_controller.rb is a fairly complex file. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	It contains a lot of methods that are long and hard to understand, these methods need to be broken down into simpler and more specific methods that are easier to read/understand. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	Also, the few instances of code duplication that exist should be removed.&lt;br /&gt;
&lt;br /&gt;
== Tasks assigned ==&lt;br /&gt;
#	Complete pending tests in questionnaires_controller_spec.rb, and write integration tests for newly-created methods. Please finish one set of pending tests first before refactoring corresponding methods. &lt;br /&gt;
#	Refactor create method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	Split into several simpler methods and assign reasonable names &lt;br /&gt;
#*	Extract duplicated code into separate methods &lt;br /&gt;
#	Refactor update_quiz, save_choices method &lt;br /&gt;
#*	Write failing tests first. &lt;br /&gt;
#*	Use polymorphism to replace the long switch statements &lt;br /&gt;
#**	Move if conditions to corresponding subclasses (eg. MultipleChoiceCheckbox.rb, MultipleChoiceRadio.rb) with same method name &lt;br /&gt;
#**	Replace the conditional with the relevant method calls &lt;br /&gt;
#**	Remove duplicated code &lt;br /&gt;
#	Use find_by instead of dynamic method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	L68, L385, L386, L559, L560&lt;br /&gt;
&lt;br /&gt;
==  Tasks Completed  ==&lt;br /&gt;
&lt;br /&gt;
*Testing&lt;br /&gt;
*Refactoring&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Testing'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1)	Completed test cases for create &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
    describe '#create' do&lt;br /&gt;
      it 'redirects to questionnaires#edit page after create a new questionnaire'&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
:After writing test case&lt;br /&gt;
   describe '#create' do&lt;br /&gt;
    it 'redirects to questionnaires#edit page after create a new questionnaire' do&lt;br /&gt;
      tree_folder1 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder1).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder1).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      tree_folder2 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder2).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      allow(TreeFolder).to receive(:where).with([&amp;quot;name like ?&amp;quot;, &amp;quot;Review&amp;quot;]).and_return([tree_folder1, tree_folder2])&lt;br /&gt;
      folder_node2 = double('FolderNode')&lt;br /&gt;
      allow(folder_node2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(FolderNode).to receive(:find_by_node_object_id).and_return(folder_node2)&lt;br /&gt;
      user = double(&amp;quot;User&amp;quot;)&lt;br /&gt;
      allow(user).to receive(:id).and_return(1)&lt;br /&gt;
      params = {&lt;br /&gt;
        questionnaire: {&lt;br /&gt;
          private: &amp;quot;true&amp;quot;,&lt;br /&gt;
          type: &amp;quot;ReviewQuestionnaire&amp;quot;,&lt;br /&gt;
          name: &amp;quot;Random Name&amp;quot;,&lt;br /&gt;
          min_question_score: &amp;quot;0&amp;quot;,&lt;br /&gt;
          max_question_score: &amp;quot;5&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      session = {user: user}&lt;br /&gt;
      get :create, params, session&lt;br /&gt;
      expect(flash[:success]).to eq(&amp;quot;You have successfully created a questionnaire!&amp;quot;)&lt;br /&gt;
      response.should redirect_to(edit_questionnaire_path(id: 1))&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2)	Completed test cases for update_quiz &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
 &lt;br /&gt;
   describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page'&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page'&lt;br /&gt;
        # params = {&lt;br /&gt;
        #   id: 1,&lt;br /&gt;
        #   pid: 1,&lt;br /&gt;
        #   save: true,&lt;br /&gt;
        #   questionnaire: {&lt;br /&gt;
        #     name: 'test questionnaire',&lt;br /&gt;
        #     instructor_id: 6,&lt;br /&gt;
        #     private: 0,&lt;br /&gt;
        #     min_question_score: 0,&lt;br /&gt;
        #     max_question_score: 5,&lt;br /&gt;
        #     type: 'ReviewQuestionnaire',&lt;br /&gt;
        #     display_type: 'Review',&lt;br /&gt;
        #     instructor_loc: ''&lt;br /&gt;
        #   },&lt;br /&gt;
        #   question: {&lt;br /&gt;
        #     '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
        #     '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
        #     '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
        #   },&lt;br /&gt;
        #   quiz_question_choices: {&lt;br /&gt;
        #     '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
        #             {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
        #     '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
        #     '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
        #             {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
        #              '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
        #   }&lt;br /&gt;
        # }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
:After writing test case&lt;br /&gt;
&lt;br /&gt;
  describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 1,&lt;br /&gt;
          pid: 1&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 3,&lt;br /&gt;
          pid: 1,&lt;br /&gt;
          save: true,&lt;br /&gt;
          questionnaire: {&lt;br /&gt;
            name: 'test questionnaire',&lt;br /&gt;
            instructor_id: 6,&lt;br /&gt;
            private: 0,&lt;br /&gt;
            min_question_score: 0,&lt;br /&gt;
            max_question_score: 5,&lt;br /&gt;
            type: 'ReviewQuestionnaire',&lt;br /&gt;
            display_type: 'Review',&lt;br /&gt;
            instructor_loc: ''&lt;br /&gt;
          },&lt;br /&gt;
          question: {&lt;br /&gt;
            '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
            '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
            '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
          },&lt;br /&gt;
          quiz_question_choices: {&lt;br /&gt;
            '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
                    {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
            '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
            '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
                    {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
                     '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Refactoring'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Create method has been split into two methods create and save_questionnaire_create&lt;br /&gt;
&lt;br /&gt;
'''Before Modification:'''&lt;br /&gt;
  def create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    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;
      case display_type&lt;br /&gt;
      when 'AuthorFeedback'&lt;br /&gt;
        display_type = 'Author%Feedback'&lt;br /&gt;
      when 'CourseSurvey'&lt;br /&gt;
        display_type = 'Course%Survey'&lt;br /&gt;
      when 'TeammateReview'&lt;br /&gt;
        display_type = 'Teammate%Review'&lt;br /&gt;
      when 'GlobalSurvey'&lt;br /&gt;
        display_type = 'Global%Survey'&lt;br /&gt;
      when 'AssignmentSurvey'&lt;br /&gt;
        display_type = 'Assignment%Survey'&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&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;
&lt;br /&gt;
'''After Modification:'''&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    begin&lt;br /&gt;
      save_questionnaire_create&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&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;
&lt;br /&gt;
&lt;br /&gt;
  def save_questionnaire_create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    end&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;
    case display_type&lt;br /&gt;
    when 'AuthorFeedback'&lt;br /&gt;
      display_type = 'Author%Feedback'&lt;br /&gt;
    when 'CourseSurvey'&lt;br /&gt;
      display_type = 'Course%Survey'&lt;br /&gt;
    when 'TeammateReview'&lt;br /&gt;
      display_type = 'Teammate%Review'&lt;br /&gt;
    when 'GlobalSurvey'&lt;br /&gt;
      display_type = 'Global%Survey'&lt;br /&gt;
    when 'AssignmentSurvey'&lt;br /&gt;
      display_type = 'Assignment%Survey'&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;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For testing methods, we don't have to check the preconditions, as we have been assigned with refactoring the methods and testing those refactored methods properly.&lt;br /&gt;
&lt;br /&gt;
We check the file questionnaires_controller_spec.rb, and test the methods required to be refactored based on our modifications we have to carry out in the spec file for the testing methods.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Methods&lt;br /&gt;
! Contexts&lt;br /&gt;
|-&lt;br /&gt;
| view&lt;br /&gt;
| Properly checks the rendering of questionnaires &lt;br /&gt;
|-&lt;br /&gt;
| new&lt;br /&gt;
| Looks for system reaction to presence of whitespace&lt;br /&gt;
|-&lt;br /&gt;
| new&lt;br /&gt;
| Tests the system reaction to absence of whitespace&lt;br /&gt;
|-&lt;br /&gt;
| create&lt;br /&gt;
| Checks if newly created page can be edited for values.&lt;br /&gt;
|-&lt;br /&gt;
| update_quiz&lt;br /&gt;
| Checks if the content in the questionnaire is nil&lt;br /&gt;
|-&lt;br /&gt;
| update_quiz&lt;br /&gt;
| Also tests if the content in the questionnaire is not nil&lt;br /&gt;
|-&lt;br /&gt;
| copy, copy_questionnaire_details, assign_instructor_id&lt;br /&gt;
| Tested the redirection to the view page of the copied questionnaire&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Mmsatar2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111195</id>
		<title>CSC/ECE 517 Fall 2017/E1749 TFD questionnaire controller.rb refactor</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111195"/>
		<updated>2017-11-02T05:49:58Z</updated>

		<summary type="html">&lt;p&gt;Mmsatar2: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About ==&lt;br /&gt;
Expertiza is a website that is used and developed by NCSU students and faculty. Coded using Ruby on Rails the source code is readily available on Github -&amp;gt; https://github.com/expertiza/expertiza. The website is used by students for organizing teams, signing up for topics, reviewing other teams and  another bunch of tasks. The faculty i.e. Instructors and TAs use this website to set new tasks, add new questions and a few other tasks.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
*Shreyas Zagade&lt;br /&gt;
*Mohit Satarkar&lt;br /&gt;
*Darshan Bhandari&lt;br /&gt;
&lt;br /&gt;
==  Setting Up The Working Environment ==&lt;br /&gt;
''One of several ways to set up the environment and the one we adopted is:-'' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Ubuntu-Expertiza image (.OVA) [Recommended]''' &amp;lt;br&amp;gt;&lt;br /&gt;
:This is the link for the image. (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing) &amp;lt;br&amp;gt;&lt;br /&gt;
:And you can install VirtualBox (free) and import this image into VirtualBox. &amp;lt;br&amp;gt;&lt;br /&gt;
'''Some machine may require you to enable virtualization and then run the following commands.'''&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd expertiza &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bash ./setup.sh &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bundle install &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;rake db:migrate &amp;lt;/pre&amp;gt;&lt;br /&gt;
*For logging in as an instructor:- &amp;lt;br&amp;gt;&lt;br /&gt;
:Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
:Password: password &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Files involved==&lt;br /&gt;
&lt;br /&gt;
# questionnaire_controller.rb &lt;br /&gt;
# questionnaire_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Issues==&lt;br /&gt;
&lt;br /&gt;
:*	questionnaires_controller.rb is a fairly complex file. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	It contains a lot of methods that are long and hard to understand, these methods need to be broken down into simpler and more specific methods that are easier to read/understand. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	Also, the few instances of code duplication that exist should be removed.&lt;br /&gt;
&lt;br /&gt;
== Tasks assigned ==&lt;br /&gt;
#	Complete pending tests in questionnaires_controller_spec.rb, and write integration tests for newly-created methods. Please finish one set of pending tests first before refactoring corresponding methods. &lt;br /&gt;
#	Refactor create method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	Split into several simpler methods and assign reasonable names &lt;br /&gt;
#*	Extract duplicated code into separate methods &lt;br /&gt;
#	Refactor update_quiz, save_choices method &lt;br /&gt;
#*	Write failing tests first. &lt;br /&gt;
#*	Use polymorphism to replace the long switch statements &lt;br /&gt;
#**	Move if conditions to corresponding subclasses (eg. MultipleChoiceCheckbox.rb, MultipleChoiceRadio.rb) with same method name &lt;br /&gt;
#**	Replace the conditional with the relevant method calls &lt;br /&gt;
#**	Remove duplicated code &lt;br /&gt;
#	Use find_by instead of dynamic method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	L68, L385, L386, L559, L560&lt;br /&gt;
&lt;br /&gt;
==  Tasks Completed  ==&lt;br /&gt;
&lt;br /&gt;
*Testing&lt;br /&gt;
*Refactoring&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Testing'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1)	Completed test cases for create &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
    describe '#create' do&lt;br /&gt;
      it 'redirects to questionnaires#edit page after create a new questionnaire'&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
:After writing test case&lt;br /&gt;
   describe '#create' do&lt;br /&gt;
    it 'redirects to questionnaires#edit page after create a new questionnaire' do&lt;br /&gt;
      tree_folder1 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder1).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder1).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      tree_folder2 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder2).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      allow(TreeFolder).to receive(:where).with([&amp;quot;name like ?&amp;quot;, &amp;quot;Review&amp;quot;]).and_return([tree_folder1, tree_folder2])&lt;br /&gt;
      folder_node2 = double('FolderNode')&lt;br /&gt;
      allow(folder_node2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(FolderNode).to receive(:find_by_node_object_id).and_return(folder_node2)&lt;br /&gt;
      user = double(&amp;quot;User&amp;quot;)&lt;br /&gt;
      allow(user).to receive(:id).and_return(1)&lt;br /&gt;
      params = {&lt;br /&gt;
        questionnaire: {&lt;br /&gt;
          private: &amp;quot;true&amp;quot;,&lt;br /&gt;
          type: &amp;quot;ReviewQuestionnaire&amp;quot;,&lt;br /&gt;
          name: &amp;quot;Random Name&amp;quot;,&lt;br /&gt;
          min_question_score: &amp;quot;0&amp;quot;,&lt;br /&gt;
          max_question_score: &amp;quot;5&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      session = {user: user}&lt;br /&gt;
      get :create, params, session&lt;br /&gt;
      expect(flash[:success]).to eq(&amp;quot;You have successfully created a questionnaire!&amp;quot;)&lt;br /&gt;
      response.should redirect_to(edit_questionnaire_path(id: 1))&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2)	Completed test cases for update_quiz &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
 &lt;br /&gt;
   describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page'&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page'&lt;br /&gt;
        # params = {&lt;br /&gt;
        #   id: 1,&lt;br /&gt;
        #   pid: 1,&lt;br /&gt;
        #   save: true,&lt;br /&gt;
        #   questionnaire: {&lt;br /&gt;
        #     name: 'test questionnaire',&lt;br /&gt;
        #     instructor_id: 6,&lt;br /&gt;
        #     private: 0,&lt;br /&gt;
        #     min_question_score: 0,&lt;br /&gt;
        #     max_question_score: 5,&lt;br /&gt;
        #     type: 'ReviewQuestionnaire',&lt;br /&gt;
        #     display_type: 'Review',&lt;br /&gt;
        #     instructor_loc: ''&lt;br /&gt;
        #   },&lt;br /&gt;
        #   question: {&lt;br /&gt;
        #     '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
        #     '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
        #     '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
        #   },&lt;br /&gt;
        #   quiz_question_choices: {&lt;br /&gt;
        #     '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
        #             {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
        #     '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
        #     '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
        #             {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
        #              '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
        #   }&lt;br /&gt;
        # }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
:After writing test case&lt;br /&gt;
&lt;br /&gt;
  describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 1,&lt;br /&gt;
          pid: 1&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 3,&lt;br /&gt;
          pid: 1,&lt;br /&gt;
          save: true,&lt;br /&gt;
          questionnaire: {&lt;br /&gt;
            name: 'test questionnaire',&lt;br /&gt;
            instructor_id: 6,&lt;br /&gt;
            private: 0,&lt;br /&gt;
            min_question_score: 0,&lt;br /&gt;
            max_question_score: 5,&lt;br /&gt;
            type: 'ReviewQuestionnaire',&lt;br /&gt;
            display_type: 'Review',&lt;br /&gt;
            instructor_loc: ''&lt;br /&gt;
          },&lt;br /&gt;
          question: {&lt;br /&gt;
            '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
            '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
            '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
          },&lt;br /&gt;
          quiz_question_choices: {&lt;br /&gt;
            '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
                    {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
            '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
            '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
                    {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
                     '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Refactoring'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Create method has been split into two methods create and save_questionnaire_create&lt;br /&gt;
&lt;br /&gt;
'''Before Modification:'''&lt;br /&gt;
  def create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    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;
      case display_type&lt;br /&gt;
      when 'AuthorFeedback'&lt;br /&gt;
        display_type = 'Author%Feedback'&lt;br /&gt;
      when 'CourseSurvey'&lt;br /&gt;
        display_type = 'Course%Survey'&lt;br /&gt;
      when 'TeammateReview'&lt;br /&gt;
        display_type = 'Teammate%Review'&lt;br /&gt;
      when 'GlobalSurvey'&lt;br /&gt;
        display_type = 'Global%Survey'&lt;br /&gt;
      when 'AssignmentSurvey'&lt;br /&gt;
        display_type = 'Assignment%Survey'&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&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;
&lt;br /&gt;
'''After Modification:'''&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    begin&lt;br /&gt;
      save_questionnaire_create&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&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;
&lt;br /&gt;
&lt;br /&gt;
  def save_questionnaire_create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    end&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;
    case display_type&lt;br /&gt;
    when 'AuthorFeedback'&lt;br /&gt;
      display_type = 'Author%Feedback'&lt;br /&gt;
    when 'CourseSurvey'&lt;br /&gt;
      display_type = 'Course%Survey'&lt;br /&gt;
    when 'TeammateReview'&lt;br /&gt;
      display_type = 'Teammate%Review'&lt;br /&gt;
    when 'GlobalSurvey'&lt;br /&gt;
      display_type = 'Global%Survey'&lt;br /&gt;
    when 'AssignmentSurvey'&lt;br /&gt;
      display_type = 'Assignment%Survey'&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;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For testing methods, we don't have to check the preconditions, as we have been assigned with refactoring the methods and testing those refactored methods properly.&lt;br /&gt;
&lt;br /&gt;
We check the file questionnaires_controller_spec.rb, and test the methods required to be refactored based on our modifications we have to carry out in the spec file for the testing methods.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Methods&lt;br /&gt;
! Contexts&lt;br /&gt;
|-&lt;br /&gt;
| view&lt;br /&gt;
| Properly checks the rendering of questionnaires &lt;br /&gt;
|-&lt;br /&gt;
| new&lt;br /&gt;
| Looks for system reaction to presence and absence of whitespace&lt;br /&gt;
|-&lt;br /&gt;
| create&lt;br /&gt;
| Checks if newly created page can be edited for values.&lt;br /&gt;
|-&lt;br /&gt;
| update_quiz&lt;br /&gt;
| Checks if the content in the questionnaire is nil or not&lt;br /&gt;
|-&lt;br /&gt;
| copy, copy_questionnaire_details, assign_instructor_id&lt;br /&gt;
| Tested the redirection to the view page of the copied questionnaire&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Mmsatar2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111194</id>
		<title>CSC/ECE 517 Fall 2017/E1749 TFD questionnaire controller.rb refactor</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111194"/>
		<updated>2017-11-02T05:48:10Z</updated>

		<summary type="html">&lt;p&gt;Mmsatar2: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About ==&lt;br /&gt;
Expertiza is a website that is used and developed by NCSU students and faculty. Coded using Ruby on Rails the source code is readily available on Github -&amp;gt; https://github.com/expertiza/expertiza. The website is used by students for organizing teams, signing up for topics, reviewing other teams and  another bunch of tasks. The faculty i.e. Instructors and TAs use this website to set new tasks, add new questions and a few other tasks.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
*Shreyas Zagade&lt;br /&gt;
*Mohit Satarkar&lt;br /&gt;
*Darshan Bhandari&lt;br /&gt;
&lt;br /&gt;
==  Setting Up The Working Environment ==&lt;br /&gt;
''One of several ways to set up the environment and the one we adopted is:-'' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Ubuntu-Expertiza image (.OVA) [Recommended]''' &amp;lt;br&amp;gt;&lt;br /&gt;
:This is the link for the image. (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing) &amp;lt;br&amp;gt;&lt;br /&gt;
:And you can install VirtualBox (free) and import this image into VirtualBox. &amp;lt;br&amp;gt;&lt;br /&gt;
'''Some machine may require you to enable virtualization and then run the following commands.'''&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd expertiza &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bash ./setup.sh &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bundle install &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;rake db:migrate &amp;lt;/pre&amp;gt;&lt;br /&gt;
*For logging in as an instructor:- &amp;lt;br&amp;gt;&lt;br /&gt;
:Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
:Password: password &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Files involved==&lt;br /&gt;
&lt;br /&gt;
# questionnaire_controller.rb &lt;br /&gt;
# questionnaire_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Issues==&lt;br /&gt;
&lt;br /&gt;
:*	questionnaires_controller.rb is a fairly complex file. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	It contains a lot of methods that are long and hard to understand, these methods need to be broken down into simpler and more specific methods that are easier to read/understand. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	Also, the few instances of code duplication that exist should be removed.&lt;br /&gt;
&lt;br /&gt;
== Tasks assigned ==&lt;br /&gt;
#	Complete pending tests in questionnaires_controller_spec.rb, and write integration tests for newly-created methods. Please finish one set of pending tests first before refactoring corresponding methods. &lt;br /&gt;
#	Refactor create method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	Split into several simpler methods and assign reasonable names &lt;br /&gt;
#*	Extract duplicated code into separate methods &lt;br /&gt;
#	Refactor update_quiz, save_choices method &lt;br /&gt;
#*	Write failing tests first. &lt;br /&gt;
#*	Use polymorphism to replace the long switch statements &lt;br /&gt;
#**	Move if conditions to corresponding subclasses (eg. MultipleChoiceCheckbox.rb, MultipleChoiceRadio.rb) with same method name &lt;br /&gt;
#**	Replace the conditional with the relevant method calls &lt;br /&gt;
#**	Remove duplicated code &lt;br /&gt;
#	Use find_by instead of dynamic method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	L68, L385, L386, L559, L560&lt;br /&gt;
&lt;br /&gt;
==  Tasks Completed  ==&lt;br /&gt;
&lt;br /&gt;
*Testing&lt;br /&gt;
*Refactoring&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Testing'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1)	Completed test cases for create &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
    describe '#create' do&lt;br /&gt;
      it 'redirects to questionnaires#edit page after create a new questionnaire'&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
:After writing test case&lt;br /&gt;
   describe '#create' do&lt;br /&gt;
    it 'redirects to questionnaires#edit page after create a new questionnaire' do&lt;br /&gt;
      tree_folder1 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder1).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder1).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      tree_folder2 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder2).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      allow(TreeFolder).to receive(:where).with([&amp;quot;name like ?&amp;quot;, &amp;quot;Review&amp;quot;]).and_return([tree_folder1, tree_folder2])&lt;br /&gt;
      folder_node2 = double('FolderNode')&lt;br /&gt;
      allow(folder_node2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(FolderNode).to receive(:find_by_node_object_id).and_return(folder_node2)&lt;br /&gt;
      user = double(&amp;quot;User&amp;quot;)&lt;br /&gt;
      allow(user).to receive(:id).and_return(1)&lt;br /&gt;
      params = {&lt;br /&gt;
        questionnaire: {&lt;br /&gt;
          private: &amp;quot;true&amp;quot;,&lt;br /&gt;
          type: &amp;quot;ReviewQuestionnaire&amp;quot;,&lt;br /&gt;
          name: &amp;quot;Random Name&amp;quot;,&lt;br /&gt;
          min_question_score: &amp;quot;0&amp;quot;,&lt;br /&gt;
          max_question_score: &amp;quot;5&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      session = {user: user}&lt;br /&gt;
      get :create, params, session&lt;br /&gt;
      expect(flash[:success]).to eq(&amp;quot;You have successfully created a questionnaire!&amp;quot;)&lt;br /&gt;
      response.should redirect_to(edit_questionnaire_path(id: 1))&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2)	Completed test cases for update_quiz &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
 &lt;br /&gt;
   describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page'&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page'&lt;br /&gt;
        # params = {&lt;br /&gt;
        #   id: 1,&lt;br /&gt;
        #   pid: 1,&lt;br /&gt;
        #   save: true,&lt;br /&gt;
        #   questionnaire: {&lt;br /&gt;
        #     name: 'test questionnaire',&lt;br /&gt;
        #     instructor_id: 6,&lt;br /&gt;
        #     private: 0,&lt;br /&gt;
        #     min_question_score: 0,&lt;br /&gt;
        #     max_question_score: 5,&lt;br /&gt;
        #     type: 'ReviewQuestionnaire',&lt;br /&gt;
        #     display_type: 'Review',&lt;br /&gt;
        #     instructor_loc: ''&lt;br /&gt;
        #   },&lt;br /&gt;
        #   question: {&lt;br /&gt;
        #     '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
        #     '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
        #     '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
        #   },&lt;br /&gt;
        #   quiz_question_choices: {&lt;br /&gt;
        #     '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
        #             {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
        #     '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
        #     '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
        #             {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
        #              '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
        #   }&lt;br /&gt;
        # }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
:After writing test case&lt;br /&gt;
&lt;br /&gt;
  describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 1,&lt;br /&gt;
          pid: 1&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 3,&lt;br /&gt;
          pid: 1,&lt;br /&gt;
          save: true,&lt;br /&gt;
          questionnaire: {&lt;br /&gt;
            name: 'test questionnaire',&lt;br /&gt;
            instructor_id: 6,&lt;br /&gt;
            private: 0,&lt;br /&gt;
            min_question_score: 0,&lt;br /&gt;
            max_question_score: 5,&lt;br /&gt;
            type: 'ReviewQuestionnaire',&lt;br /&gt;
            display_type: 'Review',&lt;br /&gt;
            instructor_loc: ''&lt;br /&gt;
          },&lt;br /&gt;
          question: {&lt;br /&gt;
            '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
            '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
            '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
          },&lt;br /&gt;
          quiz_question_choices: {&lt;br /&gt;
            '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
                    {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
            '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
            '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
                    {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
                     '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Refactoring'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Create method has been split into two methods create and save_questionnaire_create&lt;br /&gt;
&lt;br /&gt;
'''Before Modification:'''&lt;br /&gt;
  def create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    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;
      case display_type&lt;br /&gt;
      when 'AuthorFeedback'&lt;br /&gt;
        display_type = 'Author%Feedback'&lt;br /&gt;
      when 'CourseSurvey'&lt;br /&gt;
        display_type = 'Course%Survey'&lt;br /&gt;
      when 'TeammateReview'&lt;br /&gt;
        display_type = 'Teammate%Review'&lt;br /&gt;
      when 'GlobalSurvey'&lt;br /&gt;
        display_type = 'Global%Survey'&lt;br /&gt;
      when 'AssignmentSurvey'&lt;br /&gt;
        display_type = 'Assignment%Survey'&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&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;
&lt;br /&gt;
'''After Modification:'''&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    begin&lt;br /&gt;
      save_questionnaire_create&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&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;
&lt;br /&gt;
&lt;br /&gt;
  def save_questionnaire_create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    end&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;
    case display_type&lt;br /&gt;
    when 'AuthorFeedback'&lt;br /&gt;
      display_type = 'Author%Feedback'&lt;br /&gt;
    when 'CourseSurvey'&lt;br /&gt;
      display_type = 'Course%Survey'&lt;br /&gt;
    when 'TeammateReview'&lt;br /&gt;
      display_type = 'Teammate%Review'&lt;br /&gt;
    when 'GlobalSurvey'&lt;br /&gt;
      display_type = 'Global%Survey'&lt;br /&gt;
    when 'AssignmentSurvey'&lt;br /&gt;
      display_type = 'Assignment%Survey'&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;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For testing methods, we don't have to check the preconditions, as we have been assigned with refactoring the methods and testing those refactored methods properly.&lt;br /&gt;
&lt;br /&gt;
We check the file questionnaires_controller_spec.rb, and test the methods required to be refactored based on our modifications we have to carry out in the spec file for the testing methods.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Methods&lt;br /&gt;
! Contexts&lt;br /&gt;
|-&lt;br /&gt;
| view&lt;br /&gt;
| Properly checks the rendering of questionnaires &lt;br /&gt;
|-&lt;br /&gt;
| new&lt;br /&gt;
| Looks for presence and absence of whitespace, and how the system &lt;br /&gt;
| reacts to both contexts&lt;br /&gt;
|-&lt;br /&gt;
| create&lt;br /&gt;
| Checks if newly created page can be edited for values.&lt;br /&gt;
|-&lt;br /&gt;
| update_quiz&lt;br /&gt;
| Checks both the contexts if the content in the questionnaire is nil &lt;br /&gt;
| or not&lt;br /&gt;
|-&lt;br /&gt;
| copy, copy_questionnaire_details, assign_instructor_id&lt;br /&gt;
| Tested the redirection to the view page of the copied questionnaire&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Mmsatar2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111193</id>
		<title>CSC/ECE 517 Fall 2017/E1749 TFD questionnaire controller.rb refactor</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111193"/>
		<updated>2017-11-02T05:47:02Z</updated>

		<summary type="html">&lt;p&gt;Mmsatar2: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About ==&lt;br /&gt;
Expertiza is a website that is used and developed by NCSU students and faculty. Coded using Ruby on Rails the source code is readily available on Github -&amp;gt; https://github.com/expertiza/expertiza. The website is used by students for organizing teams, signing up for topics, reviewing other teams and  another bunch of tasks. The faculty i.e. Instructors and TAs use this website to set new tasks, add new questions and a few other tasks.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
*Shreyas Zagade&lt;br /&gt;
*Mohit Satarkar&lt;br /&gt;
*Darshan Bhandari&lt;br /&gt;
&lt;br /&gt;
==  Setting Up The Working Environment ==&lt;br /&gt;
''One of several ways to set up the environment and the one we adopted is:-'' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Ubuntu-Expertiza image (.OVA) [Recommended]''' &amp;lt;br&amp;gt;&lt;br /&gt;
:This is the link for the image. (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing) &amp;lt;br&amp;gt;&lt;br /&gt;
:And you can install VirtualBox (free) and import this image into VirtualBox. &amp;lt;br&amp;gt;&lt;br /&gt;
'''Some machine may require you to enable virtualization and then run the following commands.'''&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd expertiza &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bash ./setup.sh &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bundle install &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;rake db:migrate &amp;lt;/pre&amp;gt;&lt;br /&gt;
*For logging in as an instructor:- &amp;lt;br&amp;gt;&lt;br /&gt;
:Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
:Password: password &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Files involved==&lt;br /&gt;
&lt;br /&gt;
# questionnaire_controller.rb &lt;br /&gt;
# questionnaire_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Issues==&lt;br /&gt;
&lt;br /&gt;
:*	questionnaires_controller.rb is a fairly complex file. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	It contains a lot of methods that are long and hard to understand, these methods need to be broken down into simpler and more specific methods that are easier to read/understand. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	Also, the few instances of code duplication that exist should be removed.&lt;br /&gt;
&lt;br /&gt;
== Tasks assigned ==&lt;br /&gt;
#	Complete pending tests in questionnaires_controller_spec.rb, and write integration tests for newly-created methods. Please finish one set of pending tests first before refactoring corresponding methods. &lt;br /&gt;
#	Refactor create method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	Split into several simpler methods and assign reasonable names &lt;br /&gt;
#*	Extract duplicated code into separate methods &lt;br /&gt;
#	Refactor update_quiz, save_choices method &lt;br /&gt;
#*	Write failing tests first. &lt;br /&gt;
#*	Use polymorphism to replace the long switch statements &lt;br /&gt;
#**	Move if conditions to corresponding subclasses (eg. MultipleChoiceCheckbox.rb, MultipleChoiceRadio.rb) with same method name &lt;br /&gt;
#**	Replace the conditional with the relevant method calls &lt;br /&gt;
#**	Remove duplicated code &lt;br /&gt;
#	Use find_by instead of dynamic method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	L68, L385, L386, L559, L560&lt;br /&gt;
&lt;br /&gt;
==  Tasks Completed  ==&lt;br /&gt;
&lt;br /&gt;
*Testing&lt;br /&gt;
*Refactoring&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Testing'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1)	Completed test cases for create &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
    describe '#create' do&lt;br /&gt;
      it 'redirects to questionnaires#edit page after create a new questionnaire'&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
:After writing test case&lt;br /&gt;
   describe '#create' do&lt;br /&gt;
    it 'redirects to questionnaires#edit page after create a new questionnaire' do&lt;br /&gt;
      tree_folder1 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder1).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder1).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      tree_folder2 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder2).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      allow(TreeFolder).to receive(:where).with([&amp;quot;name like ?&amp;quot;, &amp;quot;Review&amp;quot;]).and_return([tree_folder1, tree_folder2])&lt;br /&gt;
      folder_node2 = double('FolderNode')&lt;br /&gt;
      allow(folder_node2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(FolderNode).to receive(:find_by_node_object_id).and_return(folder_node2)&lt;br /&gt;
      user = double(&amp;quot;User&amp;quot;)&lt;br /&gt;
      allow(user).to receive(:id).and_return(1)&lt;br /&gt;
      params = {&lt;br /&gt;
        questionnaire: {&lt;br /&gt;
          private: &amp;quot;true&amp;quot;,&lt;br /&gt;
          type: &amp;quot;ReviewQuestionnaire&amp;quot;,&lt;br /&gt;
          name: &amp;quot;Random Name&amp;quot;,&lt;br /&gt;
          min_question_score: &amp;quot;0&amp;quot;,&lt;br /&gt;
          max_question_score: &amp;quot;5&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      session = {user: user}&lt;br /&gt;
      get :create, params, session&lt;br /&gt;
      expect(flash[:success]).to eq(&amp;quot;You have successfully created a questionnaire!&amp;quot;)&lt;br /&gt;
      response.should redirect_to(edit_questionnaire_path(id: 1))&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2)	Completed test cases for update_quiz &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
 &lt;br /&gt;
   describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page'&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page'&lt;br /&gt;
        # params = {&lt;br /&gt;
        #   id: 1,&lt;br /&gt;
        #   pid: 1,&lt;br /&gt;
        #   save: true,&lt;br /&gt;
        #   questionnaire: {&lt;br /&gt;
        #     name: 'test questionnaire',&lt;br /&gt;
        #     instructor_id: 6,&lt;br /&gt;
        #     private: 0,&lt;br /&gt;
        #     min_question_score: 0,&lt;br /&gt;
        #     max_question_score: 5,&lt;br /&gt;
        #     type: 'ReviewQuestionnaire',&lt;br /&gt;
        #     display_type: 'Review',&lt;br /&gt;
        #     instructor_loc: ''&lt;br /&gt;
        #   },&lt;br /&gt;
        #   question: {&lt;br /&gt;
        #     '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
        #     '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
        #     '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
        #   },&lt;br /&gt;
        #   quiz_question_choices: {&lt;br /&gt;
        #     '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
        #             {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
        #     '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
        #     '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
        #             {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
        #              '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
        #   }&lt;br /&gt;
        # }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
:After writing test case&lt;br /&gt;
&lt;br /&gt;
  describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 1,&lt;br /&gt;
          pid: 1&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 3,&lt;br /&gt;
          pid: 1,&lt;br /&gt;
          save: true,&lt;br /&gt;
          questionnaire: {&lt;br /&gt;
            name: 'test questionnaire',&lt;br /&gt;
            instructor_id: 6,&lt;br /&gt;
            private: 0,&lt;br /&gt;
            min_question_score: 0,&lt;br /&gt;
            max_question_score: 5,&lt;br /&gt;
            type: 'ReviewQuestionnaire',&lt;br /&gt;
            display_type: 'Review',&lt;br /&gt;
            instructor_loc: ''&lt;br /&gt;
          },&lt;br /&gt;
          question: {&lt;br /&gt;
            '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
            '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
            '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
          },&lt;br /&gt;
          quiz_question_choices: {&lt;br /&gt;
            '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
                    {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
            '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
            '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
                    {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
                     '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Refactoring'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Create method has been split into two methods create and save_questionnaire_create&lt;br /&gt;
&lt;br /&gt;
'''Before Modification:'''&lt;br /&gt;
  def create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    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;
      case display_type&lt;br /&gt;
      when 'AuthorFeedback'&lt;br /&gt;
        display_type = 'Author%Feedback'&lt;br /&gt;
      when 'CourseSurvey'&lt;br /&gt;
        display_type = 'Course%Survey'&lt;br /&gt;
      when 'TeammateReview'&lt;br /&gt;
        display_type = 'Teammate%Review'&lt;br /&gt;
      when 'GlobalSurvey'&lt;br /&gt;
        display_type = 'Global%Survey'&lt;br /&gt;
      when 'AssignmentSurvey'&lt;br /&gt;
        display_type = 'Assignment%Survey'&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&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;
&lt;br /&gt;
'''After Modification:'''&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    begin&lt;br /&gt;
      save_questionnaire_create&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&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;
&lt;br /&gt;
&lt;br /&gt;
  def save_questionnaire_create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    end&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;
    case display_type&lt;br /&gt;
    when 'AuthorFeedback'&lt;br /&gt;
      display_type = 'Author%Feedback'&lt;br /&gt;
    when 'CourseSurvey'&lt;br /&gt;
      display_type = 'Course%Survey'&lt;br /&gt;
    when 'TeammateReview'&lt;br /&gt;
      display_type = 'Teammate%Review'&lt;br /&gt;
    when 'GlobalSurvey'&lt;br /&gt;
      display_type = 'Global%Survey'&lt;br /&gt;
    when 'AssignmentSurvey'&lt;br /&gt;
      display_type = 'Assignment%Survey'&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;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For testing methods, we don't have to check the preconditions, as we have been assigned with refactoring the methods and testing those refactored methods properly.&lt;br /&gt;
&lt;br /&gt;
We check the file questionnaires_controller_spec.rb, and test the methods required to be refactored based on our modifications we have to carry out in the spec file for the testing methods.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Methods&lt;br /&gt;
! Contexts&lt;br /&gt;
|-&lt;br /&gt;
| view&lt;br /&gt;
| Properly checks the rendering of questionnaires &lt;br /&gt;
|-&lt;br /&gt;
| new&lt;br /&gt;
| Looks for presence and absence of whitespace, and how the system &lt;br /&gt;
|reacts to both contexts&lt;br /&gt;
|-&lt;br /&gt;
| create&lt;br /&gt;
| Checks if newly created page can be edited for values.&lt;br /&gt;
|-&lt;br /&gt;
| update_quiz&lt;br /&gt;
| Checks both the contexts if the content in the questionnaire is nil &lt;br /&gt;
|or not&lt;br /&gt;
|-&lt;br /&gt;
| copy, copy_questionnaire_details, assign_instructor_id&lt;br /&gt;
| Tested the redirection to the view page of the copied questionnaire&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Mmsatar2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111192</id>
		<title>CSC/ECE 517 Fall 2017/E1749 TFD questionnaire controller.rb refactor</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111192"/>
		<updated>2017-11-02T05:46:16Z</updated>

		<summary type="html">&lt;p&gt;Mmsatar2: /* Test Plan */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About ==&lt;br /&gt;
Expertiza is a website that is used and developed by NCSU students and faculty. Coded using Ruby on Rails the source code is readily available on Github -&amp;gt; https://github.com/expertiza/expertiza. The website is used by students for organizing teams, signing up for topics, reviewing other teams and  another bunch of tasks. The faculty i.e. Instructors and TAs use this website to set new tasks, add new questions and a few other tasks.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
*Shreyas Zagade&lt;br /&gt;
*Mohit Satarkar&lt;br /&gt;
*Darshan Bhandari&lt;br /&gt;
&lt;br /&gt;
==  Setting Up The Working Environment ==&lt;br /&gt;
''One of several ways to set up the environment and the one we adopted is:-'' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Ubuntu-Expertiza image (.OVA) [Recommended]''' &amp;lt;br&amp;gt;&lt;br /&gt;
:This is the link for the image. (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing) &amp;lt;br&amp;gt;&lt;br /&gt;
:And you can install VirtualBox (free) and import this image into VirtualBox. &amp;lt;br&amp;gt;&lt;br /&gt;
'''Some machine may require you to enable virtualization and then run the following commands.'''&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd expertiza &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bash ./setup.sh &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bundle install &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;rake db:migrate &amp;lt;/pre&amp;gt;&lt;br /&gt;
*For logging in as an instructor:- &amp;lt;br&amp;gt;&lt;br /&gt;
:Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
:Password: password &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Files involved==&lt;br /&gt;
&lt;br /&gt;
# questionnaire_controller.rb &lt;br /&gt;
# questionnaire_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Issues==&lt;br /&gt;
&lt;br /&gt;
:*	questionnaires_controller.rb is a fairly complex file. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	It contains a lot of methods that are long and hard to understand, these methods need to be broken down into simpler and more specific methods that are easier to read/understand. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	Also, the few instances of code duplication that exist should be removed.&lt;br /&gt;
&lt;br /&gt;
== Tasks assigned ==&lt;br /&gt;
#	Complete pending tests in questionnaires_controller_spec.rb, and write integration tests for newly-created methods. Please finish one set of pending tests first before refactoring corresponding methods. &lt;br /&gt;
#	Refactor create method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	Split into several simpler methods and assign reasonable names &lt;br /&gt;
#*	Extract duplicated code into separate methods &lt;br /&gt;
#	Refactor update_quiz, save_choices method &lt;br /&gt;
#*	Write failing tests first. &lt;br /&gt;
#*	Use polymorphism to replace the long switch statements &lt;br /&gt;
#**	Move if conditions to corresponding subclasses (eg. MultipleChoiceCheckbox.rb, MultipleChoiceRadio.rb) with same method name &lt;br /&gt;
#**	Replace the conditional with the relevant method calls &lt;br /&gt;
#**	Remove duplicated code &lt;br /&gt;
#	Use find_by instead of dynamic method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	L68, L385, L386, L559, L560&lt;br /&gt;
&lt;br /&gt;
==  Tasks Completed  ==&lt;br /&gt;
&lt;br /&gt;
*Testing&lt;br /&gt;
*Refactoring&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Testing'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1)	Completed test cases for create &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
    describe '#create' do&lt;br /&gt;
      it 'redirects to questionnaires#edit page after create a new questionnaire'&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
:After writing test case&lt;br /&gt;
   describe '#create' do&lt;br /&gt;
    it 'redirects to questionnaires#edit page after create a new questionnaire' do&lt;br /&gt;
      tree_folder1 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder1).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder1).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      tree_folder2 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder2).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      allow(TreeFolder).to receive(:where).with([&amp;quot;name like ?&amp;quot;, &amp;quot;Review&amp;quot;]).and_return([tree_folder1, tree_folder2])&lt;br /&gt;
      folder_node2 = double('FolderNode')&lt;br /&gt;
      allow(folder_node2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(FolderNode).to receive(:find_by_node_object_id).and_return(folder_node2)&lt;br /&gt;
      user = double(&amp;quot;User&amp;quot;)&lt;br /&gt;
      allow(user).to receive(:id).and_return(1)&lt;br /&gt;
      params = {&lt;br /&gt;
        questionnaire: {&lt;br /&gt;
          private: &amp;quot;true&amp;quot;,&lt;br /&gt;
          type: &amp;quot;ReviewQuestionnaire&amp;quot;,&lt;br /&gt;
          name: &amp;quot;Random Name&amp;quot;,&lt;br /&gt;
          min_question_score: &amp;quot;0&amp;quot;,&lt;br /&gt;
          max_question_score: &amp;quot;5&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      session = {user: user}&lt;br /&gt;
      get :create, params, session&lt;br /&gt;
      expect(flash[:success]).to eq(&amp;quot;You have successfully created a questionnaire!&amp;quot;)&lt;br /&gt;
      response.should redirect_to(edit_questionnaire_path(id: 1))&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2)	Completed test cases for update_quiz &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
 &lt;br /&gt;
   describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page'&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page'&lt;br /&gt;
        # params = {&lt;br /&gt;
        #   id: 1,&lt;br /&gt;
        #   pid: 1,&lt;br /&gt;
        #   save: true,&lt;br /&gt;
        #   questionnaire: {&lt;br /&gt;
        #     name: 'test questionnaire',&lt;br /&gt;
        #     instructor_id: 6,&lt;br /&gt;
        #     private: 0,&lt;br /&gt;
        #     min_question_score: 0,&lt;br /&gt;
        #     max_question_score: 5,&lt;br /&gt;
        #     type: 'ReviewQuestionnaire',&lt;br /&gt;
        #     display_type: 'Review',&lt;br /&gt;
        #     instructor_loc: ''&lt;br /&gt;
        #   },&lt;br /&gt;
        #   question: {&lt;br /&gt;
        #     '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
        #     '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
        #     '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
        #   },&lt;br /&gt;
        #   quiz_question_choices: {&lt;br /&gt;
        #     '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
        #             {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
        #     '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
        #     '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
        #             {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
        #              '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
        #   }&lt;br /&gt;
        # }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
:After writing test case&lt;br /&gt;
&lt;br /&gt;
  describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 1,&lt;br /&gt;
          pid: 1&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 3,&lt;br /&gt;
          pid: 1,&lt;br /&gt;
          save: true,&lt;br /&gt;
          questionnaire: {&lt;br /&gt;
            name: 'test questionnaire',&lt;br /&gt;
            instructor_id: 6,&lt;br /&gt;
            private: 0,&lt;br /&gt;
            min_question_score: 0,&lt;br /&gt;
            max_question_score: 5,&lt;br /&gt;
            type: 'ReviewQuestionnaire',&lt;br /&gt;
            display_type: 'Review',&lt;br /&gt;
            instructor_loc: ''&lt;br /&gt;
          },&lt;br /&gt;
          question: {&lt;br /&gt;
            '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
            '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
            '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
          },&lt;br /&gt;
          quiz_question_choices: {&lt;br /&gt;
            '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
                    {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
            '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
            '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
                    {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
                     '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Refactoring'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Create method has been split into two methods create and save_questionnaire_create&lt;br /&gt;
&lt;br /&gt;
'''Before Modification:'''&lt;br /&gt;
  def create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    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;
      case display_type&lt;br /&gt;
      when 'AuthorFeedback'&lt;br /&gt;
        display_type = 'Author%Feedback'&lt;br /&gt;
      when 'CourseSurvey'&lt;br /&gt;
        display_type = 'Course%Survey'&lt;br /&gt;
      when 'TeammateReview'&lt;br /&gt;
        display_type = 'Teammate%Review'&lt;br /&gt;
      when 'GlobalSurvey'&lt;br /&gt;
        display_type = 'Global%Survey'&lt;br /&gt;
      when 'AssignmentSurvey'&lt;br /&gt;
        display_type = 'Assignment%Survey'&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&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;
&lt;br /&gt;
'''After Modification:'''&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    begin&lt;br /&gt;
      save_questionnaire_create&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&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;
&lt;br /&gt;
&lt;br /&gt;
  def save_questionnaire_create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    end&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;
    case display_type&lt;br /&gt;
    when 'AuthorFeedback'&lt;br /&gt;
      display_type = 'Author%Feedback'&lt;br /&gt;
    when 'CourseSurvey'&lt;br /&gt;
      display_type = 'Course%Survey'&lt;br /&gt;
    when 'TeammateReview'&lt;br /&gt;
      display_type = 'Teammate%Review'&lt;br /&gt;
    when 'GlobalSurvey'&lt;br /&gt;
      display_type = 'Global%Survey'&lt;br /&gt;
    when 'AssignmentSurvey'&lt;br /&gt;
      display_type = 'Assignment%Survey'&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;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
For testing methods, we don't have to check the preconditions, as we have been assigned with refactoring the methods and testing those refactored methods properly.&lt;br /&gt;
&lt;br /&gt;
We check the file questionnaires_controller_spec.rb, and test the methods required to be refactored based on our modifications we have to carry out in the spec file for the testing methods.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Methods&lt;br /&gt;
! Contexts&lt;br /&gt;
|-&lt;br /&gt;
| view&lt;br /&gt;
| Properly checks the rendering of questionnaires &lt;br /&gt;
|-&lt;br /&gt;
| new&lt;br /&gt;
| Looks for presence and absence of whitespace, and how the system &lt;br /&gt;
  reacts to both contexts&lt;br /&gt;
|-&lt;br /&gt;
| create&lt;br /&gt;
| Checks if newly created page can be edited for values.&lt;br /&gt;
|-&lt;br /&gt;
| update_quiz&lt;br /&gt;
| Checks both the contexts if the content in the questionnaire is nil &lt;br /&gt;
  or not&lt;br /&gt;
|-&lt;br /&gt;
| copy, copy_questionnaire_details, assign_instructor_id&lt;br /&gt;
| Tested the redirection to the view page of the copied questionnaire&lt;br /&gt;
|-&lt;/div&gt;</summary>
		<author><name>Mmsatar2</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111191</id>
		<title>CSC/ECE 517 Fall 2017/E1749 TFD questionnaire controller.rb refactor</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1749_TFD_questionnaire_controller.rb_refactor&amp;diff=111191"/>
		<updated>2017-11-02T04:36:42Z</updated>

		<summary type="html">&lt;p&gt;Mmsatar2: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About ==&lt;br /&gt;
Expertiza is a website that is used and developed by NCSU students and faculty. Coded using Ruby on Rails the source code is readily available on Github -&amp;gt; https://github.com/expertiza/expertiza. The website is used by students for organizing teams, signing up for topics, reviewing other teams and  another bunch of tasks. The faculty i.e. Instructors and TAs use this website to set new tasks, add new questions and a few other tasks.&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
*Shreyas Zagade&lt;br /&gt;
*Mohit Satarkar&lt;br /&gt;
*Darshan Bhandari&lt;br /&gt;
&lt;br /&gt;
==  Setting Up The Working Environment ==&lt;br /&gt;
''One of several ways to set up the environment and the one we adopted is:-'' &amp;lt;br&amp;gt;&lt;br /&gt;
'''Ubuntu-Expertiza image (.OVA) [Recommended]''' &amp;lt;br&amp;gt;&lt;br /&gt;
:This is the link for the image. (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing) &amp;lt;br&amp;gt;&lt;br /&gt;
:And you can install VirtualBox (free) and import this image into VirtualBox. &amp;lt;br&amp;gt;&lt;br /&gt;
'''Some machine may require you to enable virtualization and then run the following commands.'''&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;cd expertiza &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bash ./setup.sh &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;bundle install &amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;rake db:migrate &amp;lt;/pre&amp;gt;&lt;br /&gt;
*For logging in as an instructor:- &amp;lt;br&amp;gt;&lt;br /&gt;
:Username: instructor6 &amp;lt;br&amp;gt;&lt;br /&gt;
:Password: password &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Files involved==&lt;br /&gt;
&lt;br /&gt;
# questionnaire_controller.rb &lt;br /&gt;
# questionnaire_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
==Issues==&lt;br /&gt;
&lt;br /&gt;
:*	questionnaires_controller.rb is a fairly complex file. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	It contains a lot of methods that are long and hard to understand, these methods need to be broken down into simpler and more specific methods that are easier to read/understand. &amp;lt;br&amp;gt;&lt;br /&gt;
:*	Also, the few instances of code duplication that exist should be removed.&lt;br /&gt;
&lt;br /&gt;
== Tasks assigned ==&lt;br /&gt;
#	Complete pending tests in questionnaires_controller_spec.rb, and write integration tests for newly-created methods. Please finish one set of pending tests first before refactoring corresponding methods. &lt;br /&gt;
#	Refactor create method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	Split into several simpler methods and assign reasonable names &lt;br /&gt;
#*	Extract duplicated code into separate methods &lt;br /&gt;
#	Refactor update_quiz, save_choices method &lt;br /&gt;
#*	Write failing tests first. &lt;br /&gt;
#*	Use polymorphism to replace the long switch statements &lt;br /&gt;
#**	Move if conditions to corresponding subclasses (eg. MultipleChoiceCheckbox.rb, MultipleChoiceRadio.rb) with same method name &lt;br /&gt;
#**	Replace the conditional with the relevant method calls &lt;br /&gt;
#**	Remove duplicated code &lt;br /&gt;
#	Use find_by instead of dynamic method &lt;br /&gt;
#*	Write failing tests first &lt;br /&gt;
#*	L68, L385, L386, L559, L560&lt;br /&gt;
&lt;br /&gt;
==  Tasks Completed  ==&lt;br /&gt;
&lt;br /&gt;
*Testing&lt;br /&gt;
*Refactoring&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Testing'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
1)	Completed test cases for create &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
    describe '#create' do&lt;br /&gt;
      it 'redirects to questionnaires#edit page after create a new questionnaire'&lt;br /&gt;
    end&lt;br /&gt;
  &lt;br /&gt;
:After writing test case&lt;br /&gt;
   describe '#create' do&lt;br /&gt;
    it 'redirects to questionnaires#edit page after create a new questionnaire' do&lt;br /&gt;
      tree_folder1 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder1).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder1).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      tree_folder2 = double('TreeFolder')&lt;br /&gt;
      allow(tree_folder2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(tree_folder2).to receive(:node_object_id).and_return(1)&lt;br /&gt;
      allow(TreeFolder).to receive(:where).with([&amp;quot;name like ?&amp;quot;, &amp;quot;Review&amp;quot;]).and_return([tree_folder1, tree_folder2])&lt;br /&gt;
      folder_node2 = double('FolderNode')&lt;br /&gt;
      allow(folder_node2).to receive(:id).and_return(1)&lt;br /&gt;
      allow(FolderNode).to receive(:find_by_node_object_id).and_return(folder_node2)&lt;br /&gt;
      user = double(&amp;quot;User&amp;quot;)&lt;br /&gt;
      allow(user).to receive(:id).and_return(1)&lt;br /&gt;
      params = {&lt;br /&gt;
        questionnaire: {&lt;br /&gt;
          private: &amp;quot;true&amp;quot;,&lt;br /&gt;
          type: &amp;quot;ReviewQuestionnaire&amp;quot;,&lt;br /&gt;
          name: &amp;quot;Random Name&amp;quot;,&lt;br /&gt;
          min_question_score: &amp;quot;0&amp;quot;,&lt;br /&gt;
          max_question_score: &amp;quot;5&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
      session = {user: user}&lt;br /&gt;
      get :create, params, session&lt;br /&gt;
      expect(flash[:success]).to eq(&amp;quot;You have successfully created a questionnaire!&amp;quot;)&lt;br /&gt;
      response.should redirect_to(edit_questionnaire_path(id: 1))&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
2)	Completed test cases for update_quiz &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:When test case was pending&lt;br /&gt;
 &lt;br /&gt;
   describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page'&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page'&lt;br /&gt;
        # params = {&lt;br /&gt;
        #   id: 1,&lt;br /&gt;
        #   pid: 1,&lt;br /&gt;
        #   save: true,&lt;br /&gt;
        #   questionnaire: {&lt;br /&gt;
        #     name: 'test questionnaire',&lt;br /&gt;
        #     instructor_id: 6,&lt;br /&gt;
        #     private: 0,&lt;br /&gt;
        #     min_question_score: 0,&lt;br /&gt;
        #     max_question_score: 5,&lt;br /&gt;
        #     type: 'ReviewQuestionnaire',&lt;br /&gt;
        #     display_type: 'Review',&lt;br /&gt;
        #     instructor_loc: ''&lt;br /&gt;
        #   },&lt;br /&gt;
        #   question: {&lt;br /&gt;
        #     '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
        #     '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
        #     '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
        #   },&lt;br /&gt;
        #   quiz_question_choices: {&lt;br /&gt;
        #     '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
        #             {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
        #     '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
        #     '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
        #             {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
        #              '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
        #   }&lt;br /&gt;
        # }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
:After writing test case&lt;br /&gt;
&lt;br /&gt;
  describe '#update_quiz' do&lt;br /&gt;
    context 'when @questionnaire is nil' do&lt;br /&gt;
      it 'redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 1,&lt;br /&gt;
          pid: 1&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when @questionnaire is not nil' do&lt;br /&gt;
      it 'updates all quiz questions and redirects to submitted_content#view page' do&lt;br /&gt;
        params = {&lt;br /&gt;
          id: 3,&lt;br /&gt;
          pid: 1,&lt;br /&gt;
          save: true,&lt;br /&gt;
          questionnaire: {&lt;br /&gt;
            name: 'test questionnaire',&lt;br /&gt;
            instructor_id: 6,&lt;br /&gt;
            private: 0,&lt;br /&gt;
            min_question_score: 0,&lt;br /&gt;
            max_question_score: 5,&lt;br /&gt;
            type: 'ReviewQuestionnaire',&lt;br /&gt;
            display_type: 'Review',&lt;br /&gt;
            instructor_loc: ''&lt;br /&gt;
          },&lt;br /&gt;
          question: {&lt;br /&gt;
            '1' =&amp;gt; {txt: 'Q1'},&lt;br /&gt;
            '2' =&amp;gt; {txt: 'Q2'},&lt;br /&gt;
            '3' =&amp;gt; {txt: 'Q3'}&lt;br /&gt;
          },&lt;br /&gt;
          quiz_question_choices: {&lt;br /&gt;
            '1' =&amp;gt; {MultipleChoiceRadio:&lt;br /&gt;
                    {:correctindex =&amp;gt; 1, '1' =&amp;gt; {txt: 'a11'}, '2' =&amp;gt; {txt: 'a12'}, '3' =&amp;gt; {txt: 'a13'}, '4' =&amp;gt; {txt: 'a14'}}},&lt;br /&gt;
            '2' =&amp;gt; {TrueFalse: {'1' =&amp;gt; {iscorrect: 'True'}}},&lt;br /&gt;
            '3' =&amp;gt; {MultipleChoiceCheckbox:&lt;br /&gt;
                    {'1' =&amp;gt; {iscorrect: '1', txt: 'a31'}, '2' =&amp;gt; {iscorrect: '0', txt: 'a32'},&lt;br /&gt;
                     '3' =&amp;gt; {iscorrect: '1', txt: 'a33'}, '4' =&amp;gt; {iscorrect: '0', txt: 'a34'}}}&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
        get :update_quiz, params&lt;br /&gt;
        response.should redirect_to(view_submitted_content_index_path(id: params[:pid]))&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Refactoring'''&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Create method has been split into two methods create and save_questionnaire_create&lt;br /&gt;
&lt;br /&gt;
'''Before Modification:'''&lt;br /&gt;
  def create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    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;
      case display_type&lt;br /&gt;
      when 'AuthorFeedback'&lt;br /&gt;
        display_type = 'Author%Feedback'&lt;br /&gt;
      when 'CourseSurvey'&lt;br /&gt;
        display_type = 'Course%Survey'&lt;br /&gt;
      when 'TeammateReview'&lt;br /&gt;
        display_type = 'Teammate%Review'&lt;br /&gt;
      when 'GlobalSurvey'&lt;br /&gt;
        display_type = 'Global%Survey'&lt;br /&gt;
      when 'AssignmentSurvey'&lt;br /&gt;
        display_type = 'Assignment%Survey'&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&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;
&lt;br /&gt;
'''After Modification:'''&lt;br /&gt;
&lt;br /&gt;
  def create&lt;br /&gt;
    begin&lt;br /&gt;
      save_questionnaire_create&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&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;
&lt;br /&gt;
&lt;br /&gt;
  def save_questionnaire_create&lt;br /&gt;
    questionnaire_private = params[:questionnaire][:private] == &amp;quot;true&amp;quot; ? true : false&lt;br /&gt;
    display_type = params[:questionnaire][:type].split('Questionnaire')[0]&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;
    end&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;
    case display_type&lt;br /&gt;
    when 'AuthorFeedback'&lt;br /&gt;
      display_type = 'Author%Feedback'&lt;br /&gt;
    when 'CourseSurvey'&lt;br /&gt;
      display_type = 'Course%Survey'&lt;br /&gt;
    when 'TeammateReview'&lt;br /&gt;
      display_type = 'Teammate%Review'&lt;br /&gt;
    when 'GlobalSurvey'&lt;br /&gt;
      display_type = 'Global%Survey'&lt;br /&gt;
    when 'AssignmentSurvey'&lt;br /&gt;
      display_type = 'Assignment%Survey'&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;
  end&lt;br /&gt;
&lt;br /&gt;
==Test Plan==&lt;br /&gt;
The pre conditions which are required to test the methods are not applicable because the project includes the process of refactoring and testing the refactored methods.&lt;br /&gt;
&lt;br /&gt;
The response_spec.rb file does not include any edge cases. The edge cases are out of scope because the project includes refactoring and writing test cases. &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Methods&lt;br /&gt;
! Contexts&lt;br /&gt;
|-&lt;br /&gt;
| response_id&lt;br /&gt;
| tests if the response id is returned&lt;br /&gt;
|-&lt;br /&gt;
| display_as_html&lt;br /&gt;
| tests if corresponding html page is rendered based on the id passed&lt;br /&gt;
|-&lt;br /&gt;
| construct_instructor_html&lt;br /&gt;
| not tested&lt;br /&gt;
|-&lt;br /&gt;
| construct_student_html&lt;br /&gt;
| not tested&lt;br /&gt;
|-&lt;br /&gt;
| construct_review_response&lt;br /&gt;
| not tested&lt;br /&gt;
|-&lt;br /&gt;
| add_table_rows&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| additional_comment&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| total_score&lt;br /&gt;
| tests if the method computes the total score of the review&lt;br /&gt;
|-&lt;br /&gt;
| delete&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| average_score&lt;br /&gt;
| tests if the method computes the average score when the other function computes the maximum score&lt;br /&gt;
|-&lt;br /&gt;
| maximum_score&lt;br /&gt;
| tests if the method returns the maximum score of the current review&lt;br /&gt;
|-&lt;br /&gt;
| email&lt;br /&gt;
| tests if there is a call to email method in corresponding response maps&lt;br /&gt;
|-&lt;br /&gt;
| questionnaire_by_answer&lt;br /&gt;
| tests if method returns the questionnaire of the question of current answer or review questionnaire of current assignment based on the value of the answer&lt;br /&gt;
|-&lt;br /&gt;
| concatenate_all_review_comments&lt;br /&gt;
| tests if the method returns concatenated review comments&lt;br /&gt;
|-&lt;br /&gt;
| get_volume_of_review_comments&lt;br /&gt;
| tests if the method returns volumes of review comments in each round&lt;br /&gt;
|-&lt;br /&gt;
| significant_difference?&lt;br /&gt;
| tests if the method returns true when the difference between average score on same artifact from others and current score is bigger than allowed percentage otherwise false&lt;br /&gt;
|-&lt;br /&gt;
| avg_scores_and_count_for_prev_reviews&lt;br /&gt;
| tests if the method returns the average score and count of previous reviews when current response is not in current response array&lt;br /&gt;
|-&lt;br /&gt;
| notify_instructor_on_difference&lt;br /&gt;
| &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Mmsatar2</name></author>
	</entry>
</feed>