<?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=Jesankar</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=Jesankar"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Jesankar"/>
	<updated>2026-05-16T16:55:59Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1628_Visualization&amp;diff=102330</id>
		<title>CSC/ECE 517 Spring 2016 E1628 Visualization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1628_Visualization&amp;diff=102330"/>
		<updated>2016-04-26T18:31:34Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added UI tests&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Purpose =&lt;br /&gt;
The main goal of the project is to present the data in more convenient way and also improve the existing visualization present in expertiza. We plan to improve /grades/view_my_scores and grades/view_team pages.Presently /grades/view_my_scores has got many line breaks between the reviews and score is displayed in text.In grades/view_team originally there was no option to sort the data.We plan to provide an option to sort the data by avg score and also display high scored reviews on left of the table so it would be easy to analyze at simple glance.&lt;br /&gt;
&lt;br /&gt;
= Task Description =&lt;br /&gt;
#When a review is shown, use different background colors for adjacent responses or adjacent reviews, instead of so much whitespace.&lt;br /&gt;
#In the “alternate view,” &lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-alpha;padding-left:20px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Clicking on “Avg.” should sort the rows by average score, from highest to lowest.  Clicking again should change the sort order to from lowest to highest.  Clicking a 3rd time should change it back to highest to lowest, etc.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Clicking on some other button or icon should sort the columns in terms of total review scores.  Clicking once should bring the highest-scored review to the right; clicking again should bring the lowest-scored review to the left, etc.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hovering over a box that has a text comment associated with it should show the comment in a “tool tip” format.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hovering over a number in the “Question id” column should bring up a “tool tip” that shows the text of the criterion (question).&lt;br /&gt;
&amp;lt;li&amp;gt;The “Question ID” label should be changed to “Criterion”.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of approach =&lt;br /&gt;
In the view that displays the reviews for the given assignment, each of the reviews are individuals '''div''' elements. To make use of existing Bootstrap CSS for displaying individual reviews with different background color, the reviews need to be part of a table. After changing this to a table, the bootstrap's table table-striped class can be added to the table to get alternate grey and white rows. The extra white space tags, horizontal rules, are removed since the table will take care of separating individuals rows. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.a we intend to use tablesorter jQuery plugin. Tablesorter auto-detects the data types in the table and sort the rows either in ascending or descending order when a column header is clicked. &lt;br /&gt;
&lt;br /&gt;
'''Install'''&amp;lt;br/&amp;gt;&lt;br /&gt;
Add the following line in Gemfile&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem 'jquery-tablesorter'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Usage'''&amp;lt;br/&amp;gt;&lt;br /&gt;
In the table add table sorter class as shown below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table id=&amp;quot;myTable&amp;quot; class=&amp;quot;tablesorter&amp;quot;&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.c and 2.d we will be including &amp;quot;tooltip&amp;quot; offered by Bootstrap to all the cells in the table with title attribute set to contain comment or criterion based on the data cell. The following attributes should be added to the respective cells in the table to get the tooltip text on hover&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
data-toggle=&amp;quot;tooltip&amp;quot; title=&amp;quot;The tooltip text goes here&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.e we will be renaming &amp;quot;Question Id&amp;quot; table header to &amp;quot;Criterion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
= Mock-ups = &lt;br /&gt;
The UI mock-ups for the tasks of the project are shown below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Colored background for different reviews'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Striped-table.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Individual reviews before modification'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:View myscore table original.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Individual reviews after modification'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:View myscore table modified.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Alternate view before modification'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Grades alternate view criteria old.png ]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Alternate view after modification'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Grades alternate view criteria modified.png ]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Tooltip for individual cells''' (Note: The screenshot utility doesn't capture the mouse pointer)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:View scores alternate tooltip.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:View scores alternate tooltip criterion.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Files =&lt;br /&gt;
These are the files we will be modifying&lt;br /&gt;
* views/grades/_reviews.html.erb&lt;br /&gt;
* views/grades/view_team.html.erb&lt;br /&gt;
&lt;br /&gt;
=UI Testing=&lt;br /&gt;
Here are the steps necessary to perform UI testing on the project. Note that the accounts refer to the Expertiza VCL image.&lt;br /&gt;
==Background Colors and Reduced Whitespace on Reviews==&lt;br /&gt;
# Login as ''student1864'', password is ''password''.&lt;br /&gt;
# Select the ''Final project'' assignment.&lt;br /&gt;
# Select ''Your scores''.&lt;br /&gt;
# Select ''show reviews''.&lt;br /&gt;
#* You'll see that reviews alternate in color between light gray and white. Some extra whitespace has been removed between reviews, so they appear more compact.&lt;br /&gt;
# Select ''show review'' next to Review 1 in Round 2.&lt;br /&gt;
#* Here you'll see that the questions alternate in color between light yellow and light blue. The point value for the question is displayed in a colored circle. The colors are the same as in the heat table in the alternate view. The maximum point value is not located to the right of the question text. Extra whitespace has been removed.&lt;br /&gt;
&lt;br /&gt;
==Alternate View Changes==&lt;br /&gt;
# Login as ''student1864'', password is ''password''.&lt;br /&gt;
# Select the ''Final project'' assignment.&lt;br /&gt;
# Select ''Alternate view''.&lt;br /&gt;
#* The ''Question Id'' column has been renamed to ''Criterion''.&lt;br /&gt;
#* Hovering over a cell in the ''Criterion'' column will display a tooltip that shows the question text for that row.&lt;br /&gt;
#* Hovering over any cell in a review column will show the response text for the corresponding question and review.&lt;br /&gt;
#* The ''Avg'' column is sortable. Clicking it will sort in ascending order, then descending order, then back to ascending order.&lt;br /&gt;
#* The ''Criterion'' column is also sortable. This is so that the original ordering of the rows can be restored.&lt;br /&gt;
#* There are two links, ''ASC'' and ''DESC'' underneath the table. Clicking them will sort the review columns in the table in ascending/descending order of total review score.&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1628_Visualization&amp;diff=102329</id>
		<title>CSC/ECE 517 Spring 2016 E1628 Visualization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1628_Visualization&amp;diff=102329"/>
		<updated>2016-04-26T18:23:54Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added UI Testing section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Purpose =&lt;br /&gt;
The main goal of the project is to present the data in more convenient way and also improve the existing visualization present in expertiza. We plan to improve /grades/view_my_scores and grades/view_team pages.Presently /grades/view_my_scores has got many line breaks between the reviews and score is displayed in text.In grades/view_team originally there was no option to sort the data.We plan to provide an option to sort the data by avg score and also display high scored reviews on left of the table so it would be easy to analyze at simple glance.&lt;br /&gt;
&lt;br /&gt;
= Task Description =&lt;br /&gt;
#When a review is shown, use different background colors for adjacent responses or adjacent reviews, instead of so much whitespace.&lt;br /&gt;
#In the “alternate view,” &lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-alpha;padding-left:20px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Clicking on “Avg.” should sort the rows by average score, from highest to lowest.  Clicking again should change the sort order to from lowest to highest.  Clicking a 3rd time should change it back to highest to lowest, etc.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Clicking on some other button or icon should sort the columns in terms of total review scores.  Clicking once should bring the highest-scored review to the right; clicking again should bring the lowest-scored review to the left, etc.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hovering over a box that has a text comment associated with it should show the comment in a “tool tip” format.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hovering over a number in the “Question id” column should bring up a “tool tip” that shows the text of the criterion (question).&lt;br /&gt;
&amp;lt;li&amp;gt;The “Question ID” label should be changed to “Criterion”.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of approach =&lt;br /&gt;
In the view that displays the reviews for the given assignment, each of the reviews are individuals '''div''' elements. To make use of existing Bootstrap CSS for displaying individual reviews with different background color, the reviews need to be part of a table. After changing this to a table, the bootstrap's table table-striped class can be added to the table to get alternate grey and white rows. The extra white space tags, horizontal rules, are removed since the table will take care of separating individuals rows. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.a we intend to use tablesorter jQuery plugin. Tablesorter auto-detects the data types in the table and sort the rows either in ascending or descending order when a column header is clicked. &lt;br /&gt;
&lt;br /&gt;
'''Install'''&amp;lt;br/&amp;gt;&lt;br /&gt;
Add the following line in Gemfile&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem 'jquery-tablesorter'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Usage'''&amp;lt;br/&amp;gt;&lt;br /&gt;
In the table add table sorter class as shown below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table id=&amp;quot;myTable&amp;quot; class=&amp;quot;tablesorter&amp;quot;&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.c and 2.d we will be including &amp;quot;tooltip&amp;quot; offered by Bootstrap to all the cells in the table with title attribute set to contain comment or criterion based on the data cell. The following attributes should be added to the respective cells in the table to get the tooltip text on hover&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
data-toggle=&amp;quot;tooltip&amp;quot; title=&amp;quot;The tooltip text goes here&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.e we will be renaming &amp;quot;Question Id&amp;quot; table header to &amp;quot;Criterion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
= Mock-ups = &lt;br /&gt;
The UI mock-ups for the tasks of the project are shown below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Colored background for different reviews'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Striped-table.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Individual reviews before modification'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:View myscore table original.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Individual reviews after modification'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:View myscore table modified.png]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Alternate view before modification'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Grades alternate view criteria old.png ]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Alternate view after modification'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Grades alternate view criteria modified.png ]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Tooltip for individual cells''' (Note: The screenshot utility doesn't capture the mouse pointer)&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:View scores alternate tooltip.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:View scores alternate tooltip criterion.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Files =&lt;br /&gt;
These are the files we will be modifying&lt;br /&gt;
* views/grades/_reviews.html.erb&lt;br /&gt;
* views/grades/view_team.html.erb&lt;br /&gt;
&lt;br /&gt;
=UI Testing=&lt;br /&gt;
Here are the steps necessary to perform UI testing on the project. Note that the accounts refer to the Expertiza VCL image.&lt;br /&gt;
==Background Colors and Reduced Whitespace on Reviews==&lt;br /&gt;
# Login as ''student1864'', password is ''password''.&lt;br /&gt;
# Select the ''Final project'' assignment.&lt;br /&gt;
# Select ''Your scores''.&lt;br /&gt;
# Select ''show reviews''. You'll see that reviews alternate in color between light gray and white. Some extra whitespace has been removed between reviews, so they appear more compact.&lt;br /&gt;
# Select ''show review'' next to Review 1 in Round 2. Here you'll see that the questions alternate in color between light yellow and light blue. The point value for the question is displayed in a colored circle. The colors are the same as in the heat table in the alternate view. The maximum point value is not located to the right of the question text. Extra whitespace has been removed.&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1628_Visualization&amp;diff=101971</id>
		<title>CSC/ECE 517 Spring 2016 E1628 Visualization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1628_Visualization&amp;diff=101971"/>
		<updated>2016-04-09T16:21:54Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: /* Files Modified */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Purpose =&lt;br /&gt;
This project is intended to enhance the visualizations currently provided by Expertiza&lt;br /&gt;
&lt;br /&gt;
= Task Description =&lt;br /&gt;
#When a review is shown, use different background colors for adjacent responses or adjacent reviews, instead of so much whitespace.&lt;br /&gt;
#In the “alternate view,” &lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-alpha;padding-left:20px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Clicking on “Avg.” should sort the rows by average score, from highest to lowest.  Clicking again should change the sort order to from lowest to highest.  Clicking a 3rd time should change it back to highest to lowest, etc.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Clicking on some other button or icon should sort the columns in terms of total review scores.  Clicking once should bring the highest-scored review to the right; clicking again should bring the lowest-scored review to the left, etc.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hovering over a box that has a text comment associated with it should show the comment in a “tool tip” format.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hovering over a number in the “Question id” column should bring up a “tool tip” that shows the text of the criterion (question).&lt;br /&gt;
&amp;lt;li&amp;gt;The “Question ID” label should be changed to “Criterion”.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of approach =&lt;br /&gt;
In the view that displays the reviews for the given assignment, each of the reviews are individuals '''div''' elements. To make use of existing Bootstrap CSS for displaying individual reviews with different background color, the reviews need to be part of a table. After changing this to a table, the bootstrap's table table-striped class can be added to the table to get alternate grey and white rows. The extra white space tags, horizontal rules, are removed since the table will take care of separating individuals rows. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.a we intend to use tablesorter jQuery plugin. Tablesorter auto-detects the data types in the table and sort the rows either in ascending or descending order when a column header is clicked. &lt;br /&gt;
&lt;br /&gt;
'''Install'''&amp;lt;br/&amp;gt;&lt;br /&gt;
Add the following line in Gemfile&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem 'jquery-tablesorter'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Usage'''&amp;lt;br/&amp;gt;&lt;br /&gt;
In the table add table sorter class as shown below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table id=&amp;quot;myTable&amp;quot; class=&amp;quot;tablesorter&amp;quot;&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.c and 2.d we will be including &amp;quot;tooltip&amp;quot; offered by Bootstrap to all the cells in the table with title attribute set to contain comment or criterion based on the data cell. The following attributes should be added to the respective cells in the table to get the tooltip text on hover&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
data-toggle=&amp;quot;tooltip&amp;quot; title=&amp;quot;The tooltip text goes here&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.e we will be renaming &amp;quot;Question Id&amp;quot; table header to &amp;quot;Criterion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
= Mock-ups = &lt;br /&gt;
The UI mock-ups for the tasks of the project are shown below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Colored background for different review'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Striped-table.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Sortable AVG column in the alternate view'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Avg-sorted.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Avg-rev-sorted.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Files Modified =&lt;br /&gt;
&lt;br /&gt;
* views/grades/_reviews.html.erb&lt;br /&gt;
* views/grades/view_team.html.erb&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1628_Visualization&amp;diff=101970</id>
		<title>CSC/ECE 517 Spring 2016 E1628 Visualization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1628_Visualization&amp;diff=101970"/>
		<updated>2016-04-09T16:19:59Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added to files modified&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Purpose =&lt;br /&gt;
This project is intended to enhance the visualizations currently provided by Expertiza&lt;br /&gt;
&lt;br /&gt;
= Task Description =&lt;br /&gt;
#When a review is shown, use different background colors for adjacent responses or adjacent reviews, instead of so much whitespace.&lt;br /&gt;
#In the “alternate view,” &lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-alpha;padding-left:20px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Clicking on “Avg.” should sort the rows by average score, from highest to lowest.  Clicking again should change the sort order to from lowest to highest.  Clicking a 3rd time should change it back to highest to lowest, etc.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Clicking on some other button or icon should sort the columns in terms of total review scores.  Clicking once should bring the highest-scored review to the right; clicking again should bring the lowest-scored review to the left, etc.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hovering over a box that has a text comment associated with it should show the comment in a “tool tip” format.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hovering over a number in the “Question id” column should bring up a “tool tip” that shows the text of the criterion (question).&lt;br /&gt;
&amp;lt;li&amp;gt;The “Question ID” label should be changed to “Criterion”.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of approach =&lt;br /&gt;
In the view that displays the reviews for the given assignment, each of the reviews are individuals '''div''' elements. To make use of existing Bootstrap CSS for displaying individual reviews with different background color, the reviews need to be part of a table. After changing this to a table, the bootstrap's table table-striped class can be added to the table to get alternate grey and white rows. The extra white space tags, horizontal rules, are removed since the table will take care of separating individuals rows. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.a we intend to use tablesorter jQuery plugin. Tablesorter auto-detects the data types in the table and sort the rows either in ascending or descending order when a column header is clicked. &lt;br /&gt;
&lt;br /&gt;
'''Install'''&amp;lt;br/&amp;gt;&lt;br /&gt;
Add the following line in Gemfile&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem 'jquery-tablesorter'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Usage'''&amp;lt;br/&amp;gt;&lt;br /&gt;
In the table add table sorter class as shown below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table id=&amp;quot;myTable&amp;quot; class=&amp;quot;tablesorter&amp;quot;&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.c and 2.d we will be including &amp;quot;tooltip&amp;quot; offered by Bootstrap to all the cells in the table with title attribute set to contain comment or criterion based on the data cell. The following attributes should be added to the respective cells in the table to get the tooltip text on hover&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
data-toggle=&amp;quot;tooltip&amp;quot; title=&amp;quot;The tooltip text goes here&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.e we will be renaming &amp;quot;Question Id&amp;quot; table header to &amp;quot;Criterion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
= Mock-ups = &lt;br /&gt;
The UI mock-ups for the tasks of the project are shown below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Colored background for different review'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Striped-table.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Sortable AVG column in the alternate view'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Avg-sorted.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Avg-rev-sorted.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Files Modified =&lt;br /&gt;
&lt;br /&gt;
* views/grades/_reviews.html.erb&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1628_Visualization&amp;diff=101969</id>
		<title>CSC/ECE 517 Spring 2016 E1628 Visualization</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016_E1628_Visualization&amp;diff=101969"/>
		<updated>2016-04-09T15:46:53Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added files modified section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Purpose =&lt;br /&gt;
This project is intended to enhance the visualizations currently provided by Expertiza&lt;br /&gt;
&lt;br /&gt;
= Task Description =&lt;br /&gt;
#When a review is shown, use different background colors for adjacent responses or adjacent reviews, instead of so much whitespace.&lt;br /&gt;
#In the “alternate view,” &lt;br /&gt;
&amp;lt;ol style=&amp;quot;list-style-type:lower-alpha;padding-left:20px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Clicking on “Avg.” should sort the rows by average score, from highest to lowest.  Clicking again should change the sort order to from lowest to highest.  Clicking a 3rd time should change it back to highest to lowest, etc.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Clicking on some other button or icon should sort the columns in terms of total review scores.  Clicking once should bring the highest-scored review to the right; clicking again should bring the lowest-scored review to the left, etc.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hovering over a box that has a text comment associated with it should show the comment in a “tool tip” format.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Hovering over a number in the “Question id” column should bring up a “tool tip” that shows the text of the criterion (question).&lt;br /&gt;
&amp;lt;li&amp;gt;The “Question ID” label should be changed to “Criterion”.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Overview of approach =&lt;br /&gt;
In the view that displays the reviews for the given assignment, each of the reviews are individuals '''div''' elements. To make use of existing Bootstrap CSS for displaying individual reviews with different background color, the reviews need to be part of a table. After changing this to a table, the bootstrap's table table-striped class can be added to the table to get alternate grey and white rows. The extra white space tags, horizontal rules, are removed since the table will take care of separating individuals rows. &lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.a we intend to use tablesorter jQuery plugin. Tablesorter auto-detects the data types in the table and sort the rows either in ascending or descending order when a column header is clicked. &lt;br /&gt;
&lt;br /&gt;
'''Install'''&amp;lt;br/&amp;gt;&lt;br /&gt;
Add the following line in Gemfile&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
gem 'jquery-tablesorter'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
'''Usage'''&amp;lt;br/&amp;gt;&lt;br /&gt;
In the table add table sorter class as shown below&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;table id=&amp;quot;myTable&amp;quot; class=&amp;quot;tablesorter&amp;quot;&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.c and 2.d we will be including &amp;quot;tooltip&amp;quot; offered by Bootstrap to all the cells in the table with title attribute set to contain comment or criterion based on the data cell. The following attributes should be added to the respective cells in the table to get the tooltip text on hover&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
data-toggle=&amp;quot;tooltip&amp;quot; title=&amp;quot;The tooltip text goes here&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
To achieve task 2.e we will be renaming &amp;quot;Question Id&amp;quot; table header to &amp;quot;Criterion&amp;quot;&lt;br /&gt;
&lt;br /&gt;
= Mock-ups = &lt;br /&gt;
The UI mock-ups for the tasks of the project are shown below. &amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Colored background for different review'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Striped-table.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
'''Sortable AVG column in the alternate view'''&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Avg-sorted.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
[[File:Avg-rev-sorted.PNG]]&lt;br /&gt;
&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Files Modified =&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016&amp;diff=101699</id>
		<title>CSC/ECE 517 Spring 2016</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016&amp;diff=101699"/>
		<updated>2016-04-03T16:53:09Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added visualization link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Writing Assignment 1==&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Active Job]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Calibration Assignment Submissions==&lt;br /&gt;
*[[Calibration Assignment Submission (OmniAuth)]]&lt;br /&gt;
*[[Calibration Assignment Submission (Patch_verb)]]&lt;br /&gt;
&lt;br /&gt;
==Writing Assignment 2==&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Mozilla Implement HTML5 form validation]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Functional Tests for Questionnaire Controller]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016 / Expertiza Self-Review Feature]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Refactor different question types from quiz feature]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Implement private browsing]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Write automated tests for WebDriver]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Refactor sign_up_sheet_controller.rb and sign_up_topic.rb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Implement Common Parts of the CSSOM API]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Functional tests for assignment creation function]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/E1604. Functional tests for Calibration function]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Refactor and write unit tests for question type.rb]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016/Refactor response controller]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE_517_Spring_2016_OSS_M1606]]&lt;br /&gt;
&lt;br /&gt;
*[[CSC/ECE_517_Spring_2016/OSS_E1601]]&lt;br /&gt;
&lt;br /&gt;
==Final Project Design Document==&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016 M1601 Implement HTML5 form validation]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016 E1624 Compose functional tests for Suggest topics of student functionality ]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016 E1631 Team-based reviewing]]&lt;br /&gt;
*[[CSC/ECE 517 Spring 2016 E1628 Visualization]]&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101549</id>
		<title>CSC/ECE 517 Spring 2016/Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101549"/>
		<updated>2016-03-31T03:31:58Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added more steps for testing view_question_text and edit methods&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1602 OSS assignment for Spring 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
====Background====&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza has a quizzing feature which allow student authors to create quiz questions and test the peer reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
&lt;br /&gt;
====Current Implementation and Problems====&lt;br /&gt;
* Following three different types of questions are supported in quizzing feature of Expertiza&lt;br /&gt;
# Multiple Choice Radio&lt;br /&gt;
# Multiple Choice Checkbox&lt;br /&gt;
# True/False&lt;br /&gt;
* The current implementation of Quizzing feature is not consistent with the current questions and questionnaires. Since Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires. But, the current implementation is inconsistent with other questionnaires.&lt;br /&gt;
* In order to create a quiz, the existing code is written in the views which has a series of if-then structures to implement the functionality of each different question type. This kind of implementation makes the code slower and violates the principles of MVC architecture.&lt;br /&gt;
* Current HTML code doesn't looks like source code.&lt;br /&gt;
* Code is repeated for different question types.&lt;br /&gt;
* Proper Ruby naming conventions are not followed&lt;br /&gt;
====Changes Implemented====&lt;br /&gt;
* All logic moved to model. Four separate methods - &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; in order to generate the same HTML for each of the question types. We used polymorphism by declaring all these methods in &amp;lt;tt&amp;gt;QuizQuestion&amp;lt;/tt&amp;gt; which inherits from &amp;lt;tt&amp;gt;Question&amp;lt;/tt&amp;gt; and has sub-types &amp;lt;tt&amp;gt;MultipleChoiceRadio&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;MultipleChoiceCheckbox&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;TrueFalse&amp;lt;/tt&amp;gt;. &lt;br /&gt;
* When questionnaire author creates a quiz, &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a student, click 'create quiz' / 'edit quiz' on 'Your Works' page. The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is now called from &amp;lt;tt&amp;gt;/view/questionnaires/_quiz_question.html.erb&amp;lt;/tt&amp;gt;&lt;br /&gt;
* When questions are viewed by the author or the instructor, &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called. To call this on UI, you can either login as a student, click 'view quiz' on 'Your works' page or login as an instructor, find an assignment with quizzing feature and click the icon 'view quiz questions'. The 'view_question_text' calls &amp;lt;tt&amp;gt;view/questionnaires/view.html.erb&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* When the quiz takers tries to take the quiz, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a quiz taker, request a quiz to take on “Take quizzes” page, then click “begin”. This method is now called on &amp;lt;tt&amp;gt;view/student_quizzes/take_quiz&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* When the quiz taker finished taking a quiz and wants to view the quiz result again, &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a quiz taker, find a finished quiz and click “view”. This method is called on &amp;lt;tt&amp;gt;view/student_quizzes/finished_quiz&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Using polymorphism and DRY principles, code repetition has been virtually eliminated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called when the author of the quiz or the instructor views the quiz. The method is responsible for generating the HTML to display the question along with each of its choices. The correct choice(s) should be bolded. Prior to refactoring, this functionality was located in &amp;lt;tt&amp;gt;app/views/student_quizzes/review_questions.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;% questions.each do |question| %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt; &amp;lt;%= question.txt %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
        &amp;lt;% question_type = question.get_formatted_question_type%&amp;gt;&lt;br /&gt;
        Question Type: &amp;lt;%= question_type %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% if question_type == 'True/False' %&amp;gt;&lt;br /&gt;
          Correct Answer: &amp;lt;%= (QuizQuestionChoice.where(question_id: question.id, iscorrect:1).first.txt) %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Radio' %&amp;gt;&lt;br /&gt;
          &amp;lt;% correct_answer = '' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Checked' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This logic has been moved to &amp;lt;tt&amp;gt;app/models/quiz_question.rb&amp;lt;/tt&amp;gt;, so now the view simply needs to call the method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;%questions.each do |question| %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;%if question.is_a? Question%&amp;gt;&lt;br /&gt;
          &amp;lt;%=question.view_question_text.html_safe%&amp;gt;&lt;br /&gt;
        &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unit tests were added to &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; covering all three types of questions to ensure that the correct HTML is generated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is called when the author creates or edits a quiz. It makes every element of the quiz editable. Prior to refactoring, the HTML was in &amp;lt;tt&amp;gt;app/views/questionnaires/_quiz_questionnaire.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;        &lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
          &amp;lt;% questionnum=@question.id %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
            &amp;lt;td &amp;gt; &amp;lt;%= text_area &amp;quot;question[]&amp;quot;, 'txt', :cols=&amp;gt;100 %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;%  @quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id) %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
        &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% for @quiz_question_choice in @quiz_question_choices %&amp;gt;&lt;br /&gt;
          &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&lt;br /&gt;
            &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
              &amp;lt;% if @question.type==&amp;quot;MultipleChoiceCheckbox&amp;quot; %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= hidden_field_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'0') %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= check_box_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'1', @quiz_question_choice.iscorrect) %&amp;gt;&lt;br /&gt;
                  &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;MultipleChoiceRadio&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][correctindex]&amp;quot;, &amp;quot;#{i}&amp;quot;, @quiz_question_choice.iscorrect)%&amp;gt;&lt;br /&gt;
                &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;TrueFalse&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;True&amp;quot;%&amp;gt;&lt;br /&gt;
                  &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'True', @quiz_question_choice.iscorrect) %&amp;gt;   True&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;False&amp;quot;%&amp;gt;&lt;br /&gt;
                    &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'False', @quiz_question_choice.iscorrect) %&amp;gt;   False&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;/tr&amp;gt;&lt;br /&gt;
          &amp;lt;% i+=1 %&amp;gt;&lt;br /&gt;
        &amp;lt;%end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt; &lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After refactoring, the same file looked like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;&lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
      &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
         &amp;lt;%= @question.edit(i) %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt;&lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
Logic is written in multiple_choice_checkbox model for multiple choice checkbox question type. Similarly, same process is followed for remaining question types. To begin a quiz, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; is called from the model.&lt;br /&gt;
     @question = self&lt;br /&gt;
     html = &amp;quot;&amp;quot;&lt;br /&gt;
     html += label_tag(&amp;quot;#{question.id}&amp;quot;, question.txt) +&amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
     quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id)&lt;br /&gt;
     quiz_question_choices.each do |choice|&lt;br /&gt;
       if answer==&amp;quot;view&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;, choice.iscorrect)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       if answer==&amp;quot;take&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       html.html_safe&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
The logic for viewing completed question and their answers is written in &amp;lt;tt&amp;gt;app/views/student_quizzes/finished_quiz.html.erb&amp;lt;/tt&amp;gt; using a redundant if-elsif structure as shown below. &lt;br /&gt;
 &amp;lt;% if question_type.eql? 'MultipleChoiceRadio' %&amp;gt;&lt;br /&gt;
    &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |answer|  %&amp;gt;&lt;br /&gt;
      &amp;lt;% if(answer.iscorrect) %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt;&amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;/b&amp;gt; -- Correct &amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;%else%&amp;gt;&lt;br /&gt;
        &amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id).first%&amp;gt;&lt;br /&gt;
    Your answer is: &amp;lt;b&amp;gt;&amp;lt;%= user_answer.comments  %&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
    &amp;lt;%if user_answer.answer==1%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%else%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%end%&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;% elsif question_type.eql? 'MultipleChoiceCheckbox' %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;% elsif(question_type == 'TrueFalse') %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
The &amp;lt;tt&amp;gt;app/views/student_quizzes/finished_quiz.html.erb&amp;lt;/tt&amp;gt; was refactored by removing the logic from the view and making it clean. We used a single construct which determines question type and answer type by calling view_completed_question method declared in quiz class as shown below.&lt;br /&gt;
 &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;b&amp;gt;Question &amp;lt;%= i %&amp;gt;: &amp;lt;/b&amp;gt;&amp;lt;%= label_tag &amp;quot;#{question.id}&amp;quot;, question.txt %&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;%= question.view_completed_question(i,user_answer) %&amp;gt;&lt;br /&gt;
 &amp;lt;% i += 1 %&amp;gt;&lt;br /&gt;
Similarly, logic was written in models for each of the question types. Following code snippet shows &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; for true/false question type.&lt;br /&gt;
def view_completed_question(count, answer)&lt;br /&gt;
     @question = self&lt;br /&gt;
     html=&amp;quot;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Correct Answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= QuizQuestionChoice.where(question_id: @question.id,iscorrect: 1).first.txt&lt;br /&gt;
     html+= &amp;quot;&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Your answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= answer.first.coments + &amp;quot;&amp;lt;/b&amp;gt;&amp;quot;&lt;br /&gt;
     if(answer.first.answer == 1)&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/Check-icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/delete_icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
     html+= &amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''Remove irrelevant comments from the student_quizzes_controller'''&lt;br /&gt;
The &amp;lt;tt&amp;gt;student_quizzes_controller&amp;lt;/tt&amp;gt; has a few comments which are irrelevant and make the method bulky. These could be safely removed from the code.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
We added unit tests in &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; which check the generated HTML for each of the refactored methods. by We used &amp;lt;tt&amp;gt;context&amp;lt;/tt&amp;gt; blocks to incorporate tests for each type of question. Here is an example of the tests for &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;view_question_text&amp;quot; do&lt;br /&gt;
    context &amp;quot;when the question is a multiple-choice radio&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;In which city is NCSU located?&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Raleigh&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Atlanta&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Charlotte&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;North Carolina&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answer&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Raleigh&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold incorrect answers&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Atlanta&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Charlotte&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;North Carolina&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the question is a multiple-choice checkbox&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Which of the following are colors?&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Paint&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Blue&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Car&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Red&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answers&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Blue&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Red&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold incorrect answers&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Paint&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Car&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the question is true/false&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;2+2=4&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;True&amp;quot;)&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;False&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answer&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;True&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold the incorrect answer&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;False&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== UI Testing ==&lt;br /&gt;
You may want to use the following information to make UI testing easier if you are using the link in the Expertiza submission:&lt;br /&gt;
&lt;br /&gt;
'''Assignment''': Quiz Assignment&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Instructor''': super_administrator2&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Students''': student15, student16, student17, student18, student19, student20&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using the link in the Expertiza submission, you do not need a password. We made this change to facilitate testing. The committed code ''does not'' make any change for authenticating users.&lt;br /&gt;
&lt;br /&gt;
Since this project involved code refactoring, no new functionality was added. But here are tests for each method to verify they are working correctly.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
# Login as a student.&lt;br /&gt;
# Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
# Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
# If you haven't created a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link.&lt;br /&gt;
# Select &amp;quot;View quiz&amp;quot;. &lt;br /&gt;
# You should see each question, followed by the choices. The correct choice(s) will be bolded.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
# Login as a student.&lt;br /&gt;
# Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
# Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
# If you haven't created a quiz yet, go ahead and create one by clicking the &amp;quot;Create Quiz&amp;quot; link.&lt;br /&gt;
# Select &amp;quot;Edit quiz&amp;quot;.&lt;br /&gt;
# You should see each question, followed by the choices, each in an editable text field. The correct choice(s) will be checked.&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101548</id>
		<title>CSC/ECE 517 Spring 2016/Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101548"/>
		<updated>2016-03-31T03:27:37Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added UI testing steps for view_question_text and edit methods&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1602 OSS assignment for Spring 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
====Background====&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza has a quizzing feature which allow student authors to create quiz questions and test the peer reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
&lt;br /&gt;
====Current Implementation and Problems====&lt;br /&gt;
* Following three different types of questions are supported in quizzing feature of Expertiza&lt;br /&gt;
# Multiple Choice Radio&lt;br /&gt;
# Multiple Choice Checkbox&lt;br /&gt;
# True/False&lt;br /&gt;
* The current implementation of Quizzing feature is not consistent with the current questions and questionnaires. Since Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires. But, the current implementation is inconsistent with other questionnaires.&lt;br /&gt;
* In order to create a quiz, the existing code is written in the views which has a series of if-then structures to implement the functionality of each different question type. This kind of implementation makes the code slower and violates the principles of MVC architecture.&lt;br /&gt;
* Current HTML code doesn't looks like source code.&lt;br /&gt;
* Code is repeated for different question types.&lt;br /&gt;
* Proper Ruby naming conventions are not followed&lt;br /&gt;
====Changes Implemented====&lt;br /&gt;
* All logic moved to model. Four separate methods - &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; in order to generate the same HTML for each of the question types. We used polymorphism by declaring all these methods in &amp;lt;tt&amp;gt;QuizQuestion&amp;lt;/tt&amp;gt; which inherits from &amp;lt;tt&amp;gt;Question&amp;lt;/tt&amp;gt; and has sub-types &amp;lt;tt&amp;gt;MultipleChoiceRadio&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;MultipleChoiceCheckbox&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;TrueFalse&amp;lt;/tt&amp;gt;. &lt;br /&gt;
* When questionnaire author creates a quiz, &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a student, click 'create quiz' / 'edit quiz' on 'Your Works' page. The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is now called from &amp;lt;tt&amp;gt;/view/questionnaires/_quiz_question.html.erb&amp;lt;/tt&amp;gt;&lt;br /&gt;
* When questions are viewed by the author or the instructor, &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called. To call this on UI, you can either login as a student, click 'view quiz' on 'Your works' page or login as an instructor, find an assignment with quizzing feature and click the icon 'view quiz questions'. The 'view_question_text' calls &amp;lt;tt&amp;gt;view/questionnaires/view.html.erb&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* When the quiz takers tries to take the quiz, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a quiz taker, request a quiz to take on “Take quizzes” page, then click “begin”. This method is now called on &amp;lt;tt&amp;gt;view/student_quizzes/take_quiz&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* When the quiz taker finished taking a quiz and wants to view the quiz result again, &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a quiz taker, find a finished quiz and click “view”. This method is called on &amp;lt;tt&amp;gt;view/student_quizzes/finished_quiz&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Using polymorphism and DRY principles, code repetition has been virtually eliminated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called when the author of the quiz or the instructor views the quiz. The method is responsible for generating the HTML to display the question along with each of its choices. The correct choice(s) should be bolded. Prior to refactoring, this functionality was located in &amp;lt;tt&amp;gt;app/views/student_quizzes/review_questions.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;% questions.each do |question| %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt; &amp;lt;%= question.txt %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
        &amp;lt;% question_type = question.get_formatted_question_type%&amp;gt;&lt;br /&gt;
        Question Type: &amp;lt;%= question_type %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% if question_type == 'True/False' %&amp;gt;&lt;br /&gt;
          Correct Answer: &amp;lt;%= (QuizQuestionChoice.where(question_id: question.id, iscorrect:1).first.txt) %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Radio' %&amp;gt;&lt;br /&gt;
          &amp;lt;% correct_answer = '' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Checked' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This logic has been moved to &amp;lt;tt&amp;gt;app/models/quiz_question.rb&amp;lt;/tt&amp;gt;, so now the view simply needs to call the method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;%questions.each do |question| %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;%if question.is_a? Question%&amp;gt;&lt;br /&gt;
          &amp;lt;%=question.view_question_text.html_safe%&amp;gt;&lt;br /&gt;
        &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unit tests were added to &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; covering all three types of questions to ensure that the correct HTML is generated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is called when the author creates or edits a quiz. It makes every element of the quiz editable. Prior to refactoring, the HTML was in &amp;lt;tt&amp;gt;app/views/questionnaires/_quiz_questionnaire.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;        &lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
          &amp;lt;% questionnum=@question.id %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
            &amp;lt;td &amp;gt; &amp;lt;%= text_area &amp;quot;question[]&amp;quot;, 'txt', :cols=&amp;gt;100 %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;%  @quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id) %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
        &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% for @quiz_question_choice in @quiz_question_choices %&amp;gt;&lt;br /&gt;
          &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&lt;br /&gt;
            &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
              &amp;lt;% if @question.type==&amp;quot;MultipleChoiceCheckbox&amp;quot; %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= hidden_field_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'0') %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= check_box_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'1', @quiz_question_choice.iscorrect) %&amp;gt;&lt;br /&gt;
                  &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;MultipleChoiceRadio&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][correctindex]&amp;quot;, &amp;quot;#{i}&amp;quot;, @quiz_question_choice.iscorrect)%&amp;gt;&lt;br /&gt;
                &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;TrueFalse&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;True&amp;quot;%&amp;gt;&lt;br /&gt;
                  &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'True', @quiz_question_choice.iscorrect) %&amp;gt;   True&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;False&amp;quot;%&amp;gt;&lt;br /&gt;
                    &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'False', @quiz_question_choice.iscorrect) %&amp;gt;   False&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;/tr&amp;gt;&lt;br /&gt;
          &amp;lt;% i+=1 %&amp;gt;&lt;br /&gt;
        &amp;lt;%end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt; &lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After refactoring, the same file looked like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;&lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
      &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
         &amp;lt;%= @question.edit(i) %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt;&lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
Logic is written in multiple_choice_checkbox model for multiple choice checkbox question type. Similarly, same process is followed for remaining question types. To begin a quiz, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; is called from the model.&lt;br /&gt;
     @question = self&lt;br /&gt;
     html = &amp;quot;&amp;quot;&lt;br /&gt;
     html += label_tag(&amp;quot;#{question.id}&amp;quot;, question.txt) +&amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
     quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id)&lt;br /&gt;
     quiz_question_choices.each do |choice|&lt;br /&gt;
       if answer==&amp;quot;view&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;, choice.iscorrect)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       if answer==&amp;quot;take&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       html.html_safe&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
The logic for viewing completed question and their answers is written in &amp;lt;tt&amp;gt;app/views/student_quizzes/finished_quiz.html.erb&amp;lt;/tt&amp;gt; using a redundant if-elsif structure as shown below. &lt;br /&gt;
 &amp;lt;% if question_type.eql? 'MultipleChoiceRadio' %&amp;gt;&lt;br /&gt;
    &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |answer|  %&amp;gt;&lt;br /&gt;
      &amp;lt;% if(answer.iscorrect) %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt;&amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;/b&amp;gt; -- Correct &amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;%else%&amp;gt;&lt;br /&gt;
        &amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id).first%&amp;gt;&lt;br /&gt;
    Your answer is: &amp;lt;b&amp;gt;&amp;lt;%= user_answer.comments  %&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
    &amp;lt;%if user_answer.answer==1%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%else%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%end%&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;% elsif question_type.eql? 'MultipleChoiceCheckbox' %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;% elsif(question_type == 'TrueFalse') %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
The &amp;lt;tt&amp;gt;app/views/student_quizzes/finished_quiz.html.erb&amp;lt;/tt&amp;gt; was refactored by removing the logic from the view and making it clean. We used a single construct which determines question type and answer type by calling view_completed_question method declared in quiz class as shown below.&lt;br /&gt;
 &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;b&amp;gt;Question &amp;lt;%= i %&amp;gt;: &amp;lt;/b&amp;gt;&amp;lt;%= label_tag &amp;quot;#{question.id}&amp;quot;, question.txt %&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;%= question.view_completed_question(i,user_answer) %&amp;gt;&lt;br /&gt;
 &amp;lt;% i += 1 %&amp;gt;&lt;br /&gt;
Similarly, logic was written in models for each of the question types. Following code snippet shows &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; for true/false question type.&lt;br /&gt;
def view_completed_question(count, answer)&lt;br /&gt;
     @question = self&lt;br /&gt;
     html=&amp;quot;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Correct Answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= QuizQuestionChoice.where(question_id: @question.id,iscorrect: 1).first.txt&lt;br /&gt;
     html+= &amp;quot;&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Your answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= answer.first.coments + &amp;quot;&amp;lt;/b&amp;gt;&amp;quot;&lt;br /&gt;
     if(answer.first.answer == 1)&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/Check-icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/delete_icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
     html+= &amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''Remove irrelevant comments from the student_quizzes_controller'''&lt;br /&gt;
The &amp;lt;tt&amp;gt;student_quizzes_controller&amp;lt;/tt&amp;gt; has a few comments which are irrelevant and make the method bulky. These could be safely removed from the code.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
We added unit tests in &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; which check the generated HTML for each of the refactored methods. by We used &amp;lt;tt&amp;gt;context&amp;lt;/tt&amp;gt; blocks to incorporate tests for each type of question. Here is an example of the tests for &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;view_question_text&amp;quot; do&lt;br /&gt;
    context &amp;quot;when the question is a multiple-choice radio&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;In which city is NCSU located?&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Raleigh&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Atlanta&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Charlotte&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;North Carolina&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answer&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Raleigh&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold incorrect answers&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Atlanta&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Charlotte&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;North Carolina&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the question is a multiple-choice checkbox&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Which of the following are colors?&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Paint&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Blue&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Car&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Red&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answers&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Blue&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Red&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold incorrect answers&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Paint&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Car&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the question is true/false&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;2+2=4&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;True&amp;quot;)&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;False&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answer&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;True&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold the incorrect answer&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;False&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== UI Testing ==&lt;br /&gt;
You may want to use the following information to make UI testing easier if you are using the link in the Expertiza submission:&lt;br /&gt;
&lt;br /&gt;
'''Assignment''': Quiz Assignment&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Instructor''': super_administrator2&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Students''': student15, student16, student17, student18, student19, student20&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using the link in the Expertiza submission, you do not need a password. We made this change to facilitate testing. The committed code ''does not'' make any change for authenticating users.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
# Login as a student.&lt;br /&gt;
# Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
# Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
# Select &amp;quot;View quiz&amp;quot;.&lt;br /&gt;
# You should see each question, followed by the choices. The correct choice(s) will be bolded.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
# Login as a student.&lt;br /&gt;
# Select an assignment that has quizzing enabled (e.g. Quiz Assignment).&lt;br /&gt;
# Select &amp;quot;Your Work&amp;quot;&lt;br /&gt;
# Select &amp;quot;Edit quiz&amp;quot;.&lt;br /&gt;
# You should see each question, followed by the choices, each in an editable text field. The correct choice(s) will be checked.&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101547</id>
		<title>CSC/ECE 517 Spring 2016/Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101547"/>
		<updated>2016-03-31T03:17:58Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added login info&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1602 OSS assignment for Spring 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
====Background====&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza has a quizzing feature which allow student authors to create quiz questions and test the peer reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
&lt;br /&gt;
====Current Implementation and Problems====&lt;br /&gt;
* Following three different types of questions are supported in quizzing feature of Expertiza&lt;br /&gt;
# Multiple Choice Radio&lt;br /&gt;
# Multiple Choice Checkbox&lt;br /&gt;
# True/False&lt;br /&gt;
* The current implementation of Quizzing feature is not consistent with the current questions and questionnaires. Since Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires. But, the current implementation is inconsistent with other questionnaires.&lt;br /&gt;
* In order to create a quiz, the existing code is written in the views which has a series of if-then structures to implement the functionality of each different question type. This kind of implementation makes the code slower and violates the principles of MVC architecture.&lt;br /&gt;
* Current HTML code doesn't looks like source code.&lt;br /&gt;
* Code is repeated for different question types.&lt;br /&gt;
* Proper Ruby naming conventions are not followed&lt;br /&gt;
====Changes Implemented====&lt;br /&gt;
* All logic moved to model. Four separate methods - &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; in order to generate the same HTML for each of the question types. We used polymorphism by declaring all these methods in &amp;lt;tt&amp;gt;QuizQuestion&amp;lt;/tt&amp;gt; which inherits from &amp;lt;tt&amp;gt;Question&amp;lt;/tt&amp;gt; and has sub-types &amp;lt;tt&amp;gt;MultipleChoiceRadio&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;MultipleChoiceCheckbox&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;TrueFalse&amp;lt;/tt&amp;gt;. &lt;br /&gt;
* When questionnaire author creates a quiz, &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a student, click 'create quiz' / 'edit quiz' on 'Your Works' page. The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is now called from &amp;lt;tt&amp;gt;/view/questionnaires/_quiz_question.html.erb&amp;lt;/tt&amp;gt;&lt;br /&gt;
* When questions are viewed by the author or the instructor, &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called. To call this on UI, you can either login as a student, click 'view quiz' on 'Your works' page or login as an instructor, find an assignment with quizzing feature and click the icon 'view quiz questions'. The 'view_question_text' calls &amp;lt;tt&amp;gt;view/questionnaires/view.html.erb&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* When the quiz takers tries to take the quiz, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a quiz taker, request a quiz to take on “Take quizzes” page, then click “begin”. This method is now called on &amp;lt;tt&amp;gt;view/student_quizzes/take_quiz&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* When the quiz taker finished taking a quiz and wants to view the quiz result again, &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a quiz taker, find a finished quiz and click “view”. This method is called on &amp;lt;tt&amp;gt;view/student_quizzes/finished_quiz&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Using polymorphism and DRY principles, code repetition has been virtually eliminated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called when the author of the quiz or the instructor views the quiz. The method is responsible for generating the HTML to display the question along with each of its choices. The correct choice(s) should be bolded. Prior to refactoring, this functionality was located in &amp;lt;tt&amp;gt;app/views/student_quizzes/review_questions.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;% questions.each do |question| %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt; &amp;lt;%= question.txt %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
        &amp;lt;% question_type = question.get_formatted_question_type%&amp;gt;&lt;br /&gt;
        Question Type: &amp;lt;%= question_type %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% if question_type == 'True/False' %&amp;gt;&lt;br /&gt;
          Correct Answer: &amp;lt;%= (QuizQuestionChoice.where(question_id: question.id, iscorrect:1).first.txt) %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Radio' %&amp;gt;&lt;br /&gt;
          &amp;lt;% correct_answer = '' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Checked' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This logic has been moved to &amp;lt;tt&amp;gt;app/models/quiz_question.rb&amp;lt;/tt&amp;gt;, so now the view simply needs to call the method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;%questions.each do |question| %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;%if question.is_a? Question%&amp;gt;&lt;br /&gt;
          &amp;lt;%=question.view_question_text.html_safe%&amp;gt;&lt;br /&gt;
        &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unit tests were added to &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; covering all three types of questions to ensure that the correct HTML is generated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is called when the author creates or edits a quiz. It makes every element of the quiz editable. Prior to refactoring, the HTML was in &amp;lt;tt&amp;gt;app/views/questionnaires/_quiz_questionnaire.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;        &lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
          &amp;lt;% questionnum=@question.id %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
            &amp;lt;td &amp;gt; &amp;lt;%= text_area &amp;quot;question[]&amp;quot;, 'txt', :cols=&amp;gt;100 %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;%  @quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id) %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
        &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% for @quiz_question_choice in @quiz_question_choices %&amp;gt;&lt;br /&gt;
          &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&lt;br /&gt;
            &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
              &amp;lt;% if @question.type==&amp;quot;MultipleChoiceCheckbox&amp;quot; %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= hidden_field_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'0') %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= check_box_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'1', @quiz_question_choice.iscorrect) %&amp;gt;&lt;br /&gt;
                  &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;MultipleChoiceRadio&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][correctindex]&amp;quot;, &amp;quot;#{i}&amp;quot;, @quiz_question_choice.iscorrect)%&amp;gt;&lt;br /&gt;
                &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;TrueFalse&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;True&amp;quot;%&amp;gt;&lt;br /&gt;
                  &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'True', @quiz_question_choice.iscorrect) %&amp;gt;   True&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;False&amp;quot;%&amp;gt;&lt;br /&gt;
                    &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'False', @quiz_question_choice.iscorrect) %&amp;gt;   False&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;/tr&amp;gt;&lt;br /&gt;
          &amp;lt;% i+=1 %&amp;gt;&lt;br /&gt;
        &amp;lt;%end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt; &lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After refactoring, the same file looked like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;&lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
      &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
         &amp;lt;%= @question.edit(i) %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt;&lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
Logic is written in multiple_choice_checkbox model for multiple choice checkbox question type. Similarly, same process is followed for remaining question types. To begin a quiz, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; is called from the model.&lt;br /&gt;
     @question = self&lt;br /&gt;
     html = &amp;quot;&amp;quot;&lt;br /&gt;
     html += label_tag(&amp;quot;#{question.id}&amp;quot;, question.txt) +&amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
     quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id)&lt;br /&gt;
     quiz_question_choices.each do |choice|&lt;br /&gt;
       if answer==&amp;quot;view&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;, choice.iscorrect)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       if answer==&amp;quot;take&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       html.html_safe&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
The logic for viewing completed question and their answers is written in &amp;lt;tt&amp;gt;app/views/student_quizzes/finished_quiz.html.erb&amp;lt;/tt&amp;gt; using a redundant if-elsif structure as shown below. &lt;br /&gt;
 &amp;lt;% if question_type.eql? 'MultipleChoiceRadio' %&amp;gt;&lt;br /&gt;
    &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |answer|  %&amp;gt;&lt;br /&gt;
      &amp;lt;% if(answer.iscorrect) %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt;&amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;/b&amp;gt; -- Correct &amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;%else%&amp;gt;&lt;br /&gt;
        &amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id).first%&amp;gt;&lt;br /&gt;
    Your answer is: &amp;lt;b&amp;gt;&amp;lt;%= user_answer.comments  %&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
    &amp;lt;%if user_answer.answer==1%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%else%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%end%&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;% elsif question_type.eql? 'MultipleChoiceCheckbox' %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;% elsif(question_type == 'TrueFalse') %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
The &amp;lt;tt&amp;gt;app/views/student_quizzes/finished_quiz.html.erb&amp;lt;/tt&amp;gt; was refactored by removing the logic from the view and making it clean. We used a single construct which determines question type and answer type by calling view_completed_question method declared in quiz class as shown below.&lt;br /&gt;
 &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;b&amp;gt;Question &amp;lt;%= i %&amp;gt;: &amp;lt;/b&amp;gt;&amp;lt;%= label_tag &amp;quot;#{question.id}&amp;quot;, question.txt %&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;%= question.view_completed_question(i,user_answer) %&amp;gt;&lt;br /&gt;
 &amp;lt;% i += 1 %&amp;gt;&lt;br /&gt;
Similarly, logic was written in models for each of the question types. Following code snippet shows &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; for true/false question type.&lt;br /&gt;
def view_completed_question(count, answer)&lt;br /&gt;
     @question = self&lt;br /&gt;
     html=&amp;quot;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Correct Answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= QuizQuestionChoice.where(question_id: @question.id,iscorrect: 1).first.txt&lt;br /&gt;
     html+= &amp;quot;&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Your answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= answer.first.coments + &amp;quot;&amp;lt;/b&amp;gt;&amp;quot;&lt;br /&gt;
     if(answer.first.answer == 1)&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/Check-icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/delete_icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
     html+= &amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''Remove irrelevant comments from the student_quizzes_controller'''&lt;br /&gt;
The &amp;lt;tt&amp;gt;student_quizzes_controller&amp;lt;/tt&amp;gt; has a few comments which are irrelevant and make the method bulky. These could be safely removed from the code.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
We added unit tests in &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; which check the generated HTML for each of the refactored methods. by We used &amp;lt;tt&amp;gt;context&amp;lt;/tt&amp;gt; blocks to incorporate tests for each type of question. Here is an example of the tests for &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;view_question_text&amp;quot; do&lt;br /&gt;
    context &amp;quot;when the question is a multiple-choice radio&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;In which city is NCSU located?&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Raleigh&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Atlanta&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Charlotte&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;North Carolina&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answer&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Raleigh&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold incorrect answers&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Atlanta&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Charlotte&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;North Carolina&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the question is a multiple-choice checkbox&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Which of the following are colors?&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Paint&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Blue&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Car&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Red&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answers&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Blue&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Red&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold incorrect answers&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Paint&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Car&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the question is true/false&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;2+2=4&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;True&amp;quot;)&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;False&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answer&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;True&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold the incorrect answer&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;False&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== UI Testing ==&lt;br /&gt;
You may want to use the following information to make UI testing easier if you are using the link in the Expertiza submission:&lt;br /&gt;
&lt;br /&gt;
'''Assignment''': Quiz Assignment&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Instructor''': super_administrator2&amp;lt;br /&amp;gt;&lt;br /&gt;
'''Students''': student15, student16, student17, student18, student19, student20&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using the link in the Expertiza submission, you do not need a password. We made this change to facilitate testing. The committed code ''does not'' make any change for authenticating users.&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101257</id>
		<title>CSC/ECE 517 Spring 2016/Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101257"/>
		<updated>2016-03-24T01:56:52Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added section on testing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1602 OSS assignment for Spring 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
====Background====&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza has a quizzing feature which allow student authors to create quiz questions and test the peer reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
&lt;br /&gt;
====Current Implementation and Problems====&lt;br /&gt;
* Following three different types of questions are supported in quizzing feature of Expertiza&lt;br /&gt;
# Multiple Choice Radio&lt;br /&gt;
# Multiple Choice Checkbox&lt;br /&gt;
# True/False&lt;br /&gt;
* The current implementation of Quizzing feature is not consistent with the current questions and questionnaires. Since Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires. But, the current implementation is inconsistent with other questionnaires.&lt;br /&gt;
* In order to create a quiz, the existing code is written in the views which has a series of if-then structures to implement the functionality of each different question type. This kind of implementation makes the code slower and violates the principles of MVC architecture.&lt;br /&gt;
* Current HTML code doesn't looks like source code.&lt;br /&gt;
* Code is repeated for different question types.&lt;br /&gt;
* Proper Ruby naming conventions are not followed&lt;br /&gt;
====Changes Implemented====&lt;br /&gt;
* All logic moved to model. Four separate methods - &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; in order to generate the same HTML for each of the question types. We used polymorphism by declaring all these methods in &amp;lt;tt&amp;gt;QuizQuestion&amp;lt;/tt&amp;gt; which inherits from &amp;lt;tt&amp;gt;Question&amp;lt;/tt&amp;gt; and has sub-types &amp;lt;tt&amp;gt;MultipleChoiceRadio&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;MultipleChoiceCheckbox&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;TrueFalse&amp;lt;/tt&amp;gt;. &lt;br /&gt;
* When questionnaire author creates a quiz, &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a student, click 'create quiz' / 'edit quiz' on 'Your Works' page. The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is now called from &amp;lt;tt&amp;gt;/view/questionnaires/_quiz_question.html.erb&amp;lt;/tt&amp;gt;&lt;br /&gt;
* When questions are viewed by the author or the instructor, &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called. To call this on UI, you can either login as a student, click 'view quiz' on 'Your works' page or login as an instructor, find an assignment with quizzing feature and click the icon 'view quiz questions'. The 'view_question_text' calls &amp;lt;tt&amp;gt;view/questionnaires/view.html.erb&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* When the quiz takers tries to take the quiz, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a quiz taker, request a quiz to take on “Take quizzes” page, then click “begin”. This method is now called on &amp;lt;tt&amp;gt;view/student_quizzes/take_quiz&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* When the quiz taker finished taking a quiz and wants to view the quiz result again, &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a quiz taker, find a finished quiz and click “view”. This method is called on &amp;lt;tt&amp;gt;view/student_quizzes/finished_quiz&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Using polymorphism and DRY principles, code repetition has been virtually eliminated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called when the author of the quiz or the instructor views the quiz. The method is responsible for generating the HTML to display the question along with each of its choices. The correct choice(s) should be bolded. Prior to refactoring, this functionality was located in &amp;lt;tt&amp;gt;app/views/student_quizzes/review_questions.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;% questions.each do |question| %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt; &amp;lt;%= question.txt %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
        &amp;lt;% question_type = question.get_formatted_question_type%&amp;gt;&lt;br /&gt;
        Question Type: &amp;lt;%= question_type %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% if question_type == 'True/False' %&amp;gt;&lt;br /&gt;
          Correct Answer: &amp;lt;%= (QuizQuestionChoice.where(question_id: question.id, iscorrect:1).first.txt) %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Radio' %&amp;gt;&lt;br /&gt;
          &amp;lt;% correct_answer = '' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Checked' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This logic has been moved to &amp;lt;tt&amp;gt;app/models/quiz_question.rb&amp;lt;/tt&amp;gt;, so now the view simply needs to call the method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;%questions.each do |question| %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;%if question.is_a? Question%&amp;gt;&lt;br /&gt;
          &amp;lt;%=question.view_question_text.html_safe%&amp;gt;&lt;br /&gt;
        &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unit tests were added to &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; covering all three types of questions to ensure that the correct HTML is generated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is called when the author creates or edits a quiz. It makes every element of the quiz editable. Prior to refactoring, the HTML was in &amp;lt;tt&amp;gt;app/views/questionnaires/_quiz_questionnaire.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;        &lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
          &amp;lt;% questionnum=@question.id %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
            &amp;lt;td &amp;gt; &amp;lt;%= text_area &amp;quot;question[]&amp;quot;, 'txt', :cols=&amp;gt;100 %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;%  @quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id) %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
        &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% for @quiz_question_choice in @quiz_question_choices %&amp;gt;&lt;br /&gt;
          &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&lt;br /&gt;
            &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
              &amp;lt;% if @question.type==&amp;quot;MultipleChoiceCheckbox&amp;quot; %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= hidden_field_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'0') %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= check_box_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'1', @quiz_question_choice.iscorrect) %&amp;gt;&lt;br /&gt;
                  &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;MultipleChoiceRadio&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][correctindex]&amp;quot;, &amp;quot;#{i}&amp;quot;, @quiz_question_choice.iscorrect)%&amp;gt;&lt;br /&gt;
                &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;TrueFalse&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;True&amp;quot;%&amp;gt;&lt;br /&gt;
                  &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'True', @quiz_question_choice.iscorrect) %&amp;gt;   True&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;False&amp;quot;%&amp;gt;&lt;br /&gt;
                    &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'False', @quiz_question_choice.iscorrect) %&amp;gt;   False&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;/tr&amp;gt;&lt;br /&gt;
          &amp;lt;% i+=1 %&amp;gt;&lt;br /&gt;
        &amp;lt;%end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt; &lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After refactoring, the same file looked like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;&lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
      &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
         &amp;lt;%= @question.edit(i) %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt;&lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
Logic is written in multiple_choice_checkbox model for multiple choice checkbox question type. Similarly, same process is followed for remaining question types. To begin a quiz, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; is called from the model.&lt;br /&gt;
     @question = self&lt;br /&gt;
     html = &amp;quot;&amp;quot;&lt;br /&gt;
     html += label_tag(&amp;quot;#{question.id}&amp;quot;, question.txt) +&amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
     quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id)&lt;br /&gt;
     quiz_question_choices.each do |choice|&lt;br /&gt;
       if answer==&amp;quot;view&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;, choice.iscorrect)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       if answer==&amp;quot;take&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       html.html_safe&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
The logic for viewing completed question and their answers is written in &amp;lt;tt&amp;gt;app/views/student_quizzes/finished_quiz.html.erb&amp;lt;/tt&amp;gt; using a redundant if-elsif structure as shown below. &lt;br /&gt;
 &amp;lt;% if question_type.eql? 'MultipleChoiceRadio' %&amp;gt;&lt;br /&gt;
    &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |answer|  %&amp;gt;&lt;br /&gt;
      &amp;lt;% if(answer.iscorrect) %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt;&amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;/b&amp;gt; -- Correct &amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;%else%&amp;gt;&lt;br /&gt;
        &amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id).first%&amp;gt;&lt;br /&gt;
    Your answer is: &amp;lt;b&amp;gt;&amp;lt;%= user_answer.comments  %&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
    &amp;lt;%if user_answer.answer==1%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%else%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%end%&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;% elsif question_type.eql? 'MultipleChoiceCheckbox' %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;% elsif(question_type == 'TrueFalse') %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
The &amp;lt;tt&amp;gt;app/views/student_quizzes/finished_quiz.html.erb&amp;lt;/tt&amp;gt; was refactored by removing the logic from the view and making it clean. We used a single construct which determines question type and answer type by calling view_completed_question method declared in quiz class as shown below.&lt;br /&gt;
 &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;b&amp;gt;Question &amp;lt;%= i %&amp;gt;: &amp;lt;/b&amp;gt;&amp;lt;%= label_tag &amp;quot;#{question.id}&amp;quot;, question.txt %&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;%= question.view_completed_question(i,user_answer) %&amp;gt;&lt;br /&gt;
 &amp;lt;% i += 1 %&amp;gt;&lt;br /&gt;
Similarly, logic was written in models for each of the question types. Following code snippet shows &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; for true/false question type.&lt;br /&gt;
def view_completed_question(count, answer)&lt;br /&gt;
     @question = self&lt;br /&gt;
     html=&amp;quot;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Correct Answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= QuizQuestionChoice.where(question_id: @question.id,iscorrect: 1).first.txt&lt;br /&gt;
     html+= &amp;quot;&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Your answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= answer.first.coments + &amp;quot;&amp;lt;/b&amp;gt;&amp;quot;&lt;br /&gt;
     if(answer.first.answer == 1)&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/Check-icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/delete_icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
     html+= &amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Remove irrelevant comments from the &amp;lt;tt&amp;gt;student_quizzes_controller&amp;lt;/tt&amp;gt; ====&lt;br /&gt;
The &amp;lt;tt&amp;gt;student_quizzes_controller&amp;lt;/tt&amp;gt; has a few comments which are irrelevant and make the method bulky. These could be safely removed from the code.&lt;br /&gt;
&lt;br /&gt;
== Unit Testing ==&lt;br /&gt;
We added unit tests in &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; which check the generated HTML for each of the refactored methods. by We used &amp;lt;tt&amp;gt;context&amp;lt;/tt&amp;gt; blocks to incorporate tests for each type of question. Here is an example of the tests for &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
describe &amp;quot;view_question_text&amp;quot; do&lt;br /&gt;
    context &amp;quot;when the question is a multiple-choice radio&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;In which city is NCSU located?&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Raleigh&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Atlanta&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;Charlotte&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;North Carolina&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answer&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Raleigh&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold incorrect answers&amp;quot; do&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Atlanta&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Charlotte&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@radio_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;North Carolina&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the question is a multiple-choice checkbox&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Which of the following are colors?&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Paint&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Blue&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Car&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;Red&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answers&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Blue&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;Red&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold incorrect answers&amp;quot; do&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Paint&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
        expect(@checkbox_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;Car&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context &amp;quot;when the question is true/false&amp;quot; do&lt;br /&gt;
      it &amp;quot;contains the text of the question&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;2+2=4&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;contains each of the choices&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;True&amp;quot;)&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;False&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;bolds the correct answer&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).to include(&amp;quot;&amp;lt;b&amp;gt;True&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
      it &amp;quot;does not bold the incorrect answer&amp;quot; do&lt;br /&gt;
        expect(@true_false_question.view_question_text.html_safe).not_to include(&amp;quot;&amp;lt;b&amp;gt;False&amp;lt;/b&amp;gt;&amp;quot;)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101193</id>
		<title>CSC/ECE 517 Spring 2016/Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101193"/>
		<updated>2016-03-24T00:36:44Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Improved formatting of method names&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1602 OSS assignment for Spring 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
====Background====&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza has a quizzing feature which allow student authors to create quiz questions and test the peer reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
&lt;br /&gt;
====Current Implementation and Problems====&lt;br /&gt;
* Following three different types of questions are supported in quizzing feature of Expertiza&lt;br /&gt;
# Multiple Choice Radio&lt;br /&gt;
# Multiple Choice Checkbox&lt;br /&gt;
# True/False&lt;br /&gt;
* The current implementation of Quizzing feature is not consistent with the current questions and questionnaires. Since Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires. But, the current implementation is inconsistent with other questionnaires.&lt;br /&gt;
* In order to create a quiz, the existing code is written in the views which has a series of if-then structures to implement the functionality of each different question type. This kind of implementation makes the code slower and violates the principles of MVC architecture.&lt;br /&gt;
* Current HTML code doesn't looks like source code.&lt;br /&gt;
* Code is repeated for different question types.&lt;br /&gt;
* Proper Ruby naming conventions are not followed&lt;br /&gt;
====Changes Implemented====&lt;br /&gt;
* All logic moved to model. Four separate methods - &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; in order to generate the same HTML for each of the question types. We used polymorphism by declaring all these methods in &amp;lt;tt&amp;gt;QuizQuestion&amp;lt;/tt&amp;gt; which inherits from &amp;lt;tt&amp;gt;Question&amp;lt;/tt&amp;gt; and has sub-types &amp;lt;tt&amp;gt;MultipleChoiceRadio&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;MultipleChoiceCheckbox&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;TrueFalse&amp;lt;/tt&amp;gt;. &lt;br /&gt;
* When questionnaire author creates a quiz, &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a student, click 'create quiz' / 'edit quiz' on 'Your Works' page. The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is now called from &amp;lt;tt&amp;gt;/view/questionnaires/_quiz_question.html.erb&amp;lt;/tt&amp;gt;&lt;br /&gt;
* When questions are viewed by the author or the instructor, &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called. To call this on UI, you can either login as a student, click 'view quiz' on 'Your works' page or login as an instructor, find an assignment with quizzing feature and click the icon 'view quiz questions'. The 'view_question_text' calls &amp;lt;tt&amp;gt;view/questionnaires/view.html.erb&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* When the quiz takers tries to take the quiz, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a quiz taker, request a quiz to take on “Take quizzes” page, then click “begin”. This method is now called on &amp;lt;tt&amp;gt;view/student_quizzes/take_quiz&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* When the quiz taker finished taking a quiz and wants to view the quiz result again, &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; is called. To call this on UI, you can login as a quiz taker, find a finished quiz and click “view”. This method is called on &amp;lt;tt&amp;gt;view/student_quizzes/finished_quiz&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Using polymorphism and DRY principles, code repetition has been virtually eliminated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called when the author of the quiz or the instructor views the quiz. The method is responsible for generating the HTML to display the question along with each of its choices. The correct choice(s) should be bolded. Prior to refactoring, this functionality was located in &amp;lt;tt&amp;gt;app/views/student_quizzes/review_questions.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;% questions.each do |question| %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt; &amp;lt;%= question.txt %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
        &amp;lt;% question_type = question.get_formatted_question_type%&amp;gt;&lt;br /&gt;
        Question Type: &amp;lt;%= question_type %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% if question_type == 'True/False' %&amp;gt;&lt;br /&gt;
          Correct Answer: &amp;lt;%= (QuizQuestionChoice.where(question_id: question.id, iscorrect:1).first.txt) %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Radio' %&amp;gt;&lt;br /&gt;
          &amp;lt;% correct_answer = '' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Checked' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This logic has been moved to &amp;lt;tt&amp;gt;app/models/quiz_question.rb&amp;lt;/tt&amp;gt;, so now the view simply needs to call the method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;%questions.each do |question| %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;%if question.is_a? Question%&amp;gt;&lt;br /&gt;
          &amp;lt;%=question.view_question_text.html_safe%&amp;gt;&lt;br /&gt;
        &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unit tests were added to &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; covering all three types of questions to ensure that the correct HTML is generated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is called when the author creates or edits a quiz. It makes every element of the quiz editable. Prior to refactoring, the HTML was in &amp;lt;tt&amp;gt;app/views/questionnaires/_quiz_questionnaire.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;        &lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
          &amp;lt;% questionnum=@question.id %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
            &amp;lt;td &amp;gt; &amp;lt;%= text_area &amp;quot;question[]&amp;quot;, 'txt', :cols=&amp;gt;100 %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;%  @quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id) %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
        &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% for @quiz_question_choice in @quiz_question_choices %&amp;gt;&lt;br /&gt;
          &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&lt;br /&gt;
            &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
              &amp;lt;% if @question.type==&amp;quot;MultipleChoiceCheckbox&amp;quot; %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= hidden_field_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'0') %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= check_box_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'1', @quiz_question_choice.iscorrect) %&amp;gt;&lt;br /&gt;
                  &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;MultipleChoiceRadio&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][correctindex]&amp;quot;, &amp;quot;#{i}&amp;quot;, @quiz_question_choice.iscorrect)%&amp;gt;&lt;br /&gt;
                &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;TrueFalse&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;True&amp;quot;%&amp;gt;&lt;br /&gt;
                  &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'True', @quiz_question_choice.iscorrect) %&amp;gt;   True&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;False&amp;quot;%&amp;gt;&lt;br /&gt;
                    &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'False', @quiz_question_choice.iscorrect) %&amp;gt;   False&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;/tr&amp;gt;&lt;br /&gt;
          &amp;lt;% i+=1 %&amp;gt;&lt;br /&gt;
        &amp;lt;%end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt; &lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After refactoring, the same file looked like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;&lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
      &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
         &amp;lt;%= @question.edit(i) %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt;&lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
Logic is written in multiple_choice_checkbox model for multiple choice checkbox question type. Similarly, same process is followed for remaining question types. To begin a quiz, &amp;lt;tt&amp;gt;complete&amp;lt;/tt&amp;gt; is called from the model.&lt;br /&gt;
     @question = self&lt;br /&gt;
     html = &amp;quot;&amp;quot;&lt;br /&gt;
     html += label_tag(&amp;quot;#{question.id}&amp;quot;, question.txt) +&amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
     quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id)&lt;br /&gt;
     quiz_question_choices.each do |choice|&lt;br /&gt;
       if answer==&amp;quot;view&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;, choice.iscorrect)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       if answer==&amp;quot;take&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       html.html_safe&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
The logic for viewing completed question and their answers is written in &amp;lt;tt&amp;gt;app/views/student_quizzes/finished_quiz.html.erb&amp;lt;/tt&amp;gt; using a redundant if-elsif structure as shown below. &lt;br /&gt;
 &amp;lt;% if question_type.eql? 'MultipleChoiceRadio' %&amp;gt;&lt;br /&gt;
    &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |answer|  %&amp;gt;&lt;br /&gt;
      &amp;lt;% if(answer.iscorrect) %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt;&amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;/b&amp;gt; -- Correct &amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;%else%&amp;gt;&lt;br /&gt;
        &amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id).first%&amp;gt;&lt;br /&gt;
    Your answer is: &amp;lt;b&amp;gt;&amp;lt;%= user_answer.comments  %&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
    &amp;lt;%if user_answer.answer==1%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%else%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%end%&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;% elsif question_type.eql? 'MultipleChoiceCheckbox' %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;% elsif(question_type == 'TrueFalse') %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
The &amp;lt;tt&amp;gt;app/views/student_quizzes/finished_quiz.html.erb&amp;lt;/tt&amp;gt; was refactored by removing the logic from the view and making it clean. We used a single construct which determines question type and answer type by calling view_completed_question method declared in quiz class as shown below.&lt;br /&gt;
 &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;b&amp;gt;Question &amp;lt;%= i %&amp;gt;: &amp;lt;/b&amp;gt;&amp;lt;%= label_tag &amp;quot;#{question.id}&amp;quot;, question.txt %&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;%= question.view_completed_question(i,user_answer) %&amp;gt;&lt;br /&gt;
 &amp;lt;% i += 1 %&amp;gt;&lt;br /&gt;
Similarly, logic was written in models for each of the question types. Following code snippet shows &amp;lt;tt&amp;gt;view_completed_question&amp;lt;/tt&amp;gt; for true/false question type.&lt;br /&gt;
def view_completed_question(count, answer)&lt;br /&gt;
     @question = self&lt;br /&gt;
     html=&amp;quot;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Correct Answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= QuizQuestionChoice.where(question_id: @question.id,iscorrect: 1).first.txt&lt;br /&gt;
     html+= &amp;quot;&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Your answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= answer.first.coments + &amp;quot;&amp;lt;/b&amp;gt;&amp;quot;&lt;br /&gt;
     if(answer.first.answer == 1)&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/Check-icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/delete_icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
     html+= &amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Remove irrelevant comments from the &amp;lt;tt&amp;gt;student_quizzes_controller&amp;lt;/tt&amp;gt; ====&lt;br /&gt;
The &amp;lt;tt&amp;gt;student_quizzes_controller&amp;lt;/tt&amp;gt; has a few comments which are irrelevant and make the method bulky. These could be safely removed from the code.&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101182</id>
		<title>CSC/ECE 517 Spring 2016/Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101182"/>
		<updated>2016-03-24T00:28:43Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1602 OSS assignment for Spring 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
====Background====&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza has a quizzing feature which allow student authors to create quiz questions and test the peer reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
&lt;br /&gt;
====Current Implementation and Problems====&lt;br /&gt;
* Following three different types of questions are supported in quizzing feature of Expertiza&lt;br /&gt;
# Multiple Choice Radio&lt;br /&gt;
# Multiple Choice Checkbox&lt;br /&gt;
# True/False&lt;br /&gt;
* The current implementation of Quizzing feature is not consistent with the current questions and questionnaires. Since Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires. But, the current implementation is inconsistent with other questionnaires.&lt;br /&gt;
* In order to create a quiz, the existing code is written in the views which has a series of if-then structures to implement the functionality of each different question type. This kind of implementation makes the code slower and violates the principles of MVC architecture.&lt;br /&gt;
* Current HTML code doesn't looks like source code.&lt;br /&gt;
* Code is repeated for different question types.&lt;br /&gt;
* Proper Ruby naming conventions are not followed&lt;br /&gt;
====Changes Implemented====&lt;br /&gt;
* All logic moved to model. Four separate methods - 'edit', 'view_question_text', 'complete' and 'view_completed_question' in order to generate the same html code for each of the question types. We used polymorphism by declaring all these methods in QuizQuestion class which inherits from Questions class and has sub-types MultipleChoiceRadio, MultipleChoiceCheckbox, and TrueFalse. &lt;br /&gt;
* When questionnaire author creates a quiz, 'edit' method is called. To call this on UI, you can login as a student, click 'create quiz' / 'edit quiz' on 'Your Works' page. The 'edit' method is now called from /view/questionnaires/_quiz_question.html.erb&lt;br /&gt;
* When questions are viewed by the author or the instructor, 'view_question_text' method is called. To call this on UI, you can either login as a student, click 'view quiz' on 'Ypur works' page or login as an instructor, find an assignment with quizzing feature and click the icon 'view quiz questions'. The 'view_question_text' calls view/questionnaires/view.html.erb&lt;br /&gt;
&lt;br /&gt;
* When the quiz takers tries to take the quiz, “complete” is called. To call this on UI, you can login as a quiz taker, request a quiz to take on “Take quizzes” page, then click “begin”. This method is now called on “view/student_quizzes/take_quiz”.&lt;br /&gt;
* When the quiz taker finished taking a quiz and wants to view the quiz result again,  “view_completed_question” is called. To call this on UI, you can login as a quiz taker, find a finished quiz and click “view”. This method is called on “view/student_quizzes/finished_quiz”.&lt;br /&gt;
* Using polymorphism and DRY principles, code repetition has been eliminated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called when the author of the quiz or the instructor views the quiz. The method is responsible for generating the HTML to display the question along with each of its choices. The correct choice(s) should be bolded. Prior to refactoring, this functionality was located in &amp;lt;tt&amp;gt;app/views/student_quizzes/review_questions.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;% questions.each do |question| %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt; &amp;lt;%= question.txt %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
        &amp;lt;% question_type = question.get_formatted_question_type%&amp;gt;&lt;br /&gt;
        Question Type: &amp;lt;%= question_type %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% if question_type == 'True/False' %&amp;gt;&lt;br /&gt;
          Correct Answer: &amp;lt;%= (QuizQuestionChoice.where(question_id: question.id, iscorrect:1).first.txt) %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Radio' %&amp;gt;&lt;br /&gt;
          &amp;lt;% correct_answer = '' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Checked' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This logic has been moved to &amp;lt;tt&amp;gt;app/models/quiz_question.rb&amp;lt;/tt&amp;gt;, so now the view simply needs to call the method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;%questions.each do |question| %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;%if question.is_a? Question%&amp;gt;&lt;br /&gt;
          &amp;lt;%=question.view_question_text.html_safe%&amp;gt;&lt;br /&gt;
        &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unit tests were added to &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; covering all three types of questions to ensure that the correct HTML is generated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;edit&amp;lt;/tt&amp;gt; method is called when the author creates or edits a quiz. It makes every element of the quiz editable. Prior to refactoring, the HTML was in &amp;lt;tt&amp;gt;app/views/questionnaires/_quiz_questionnaire.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;        &lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
          &amp;lt;% questionnum=@question.id %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
            &amp;lt;td &amp;gt; &amp;lt;%= text_area &amp;quot;question[]&amp;quot;, 'txt', :cols=&amp;gt;100 %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;%  @quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id) %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
        &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% for @quiz_question_choice in @quiz_question_choices %&amp;gt;&lt;br /&gt;
          &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&lt;br /&gt;
            &amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&lt;br /&gt;
              &amp;lt;% if @question.type==&amp;quot;MultipleChoiceCheckbox&amp;quot; %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= hidden_field_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'0') %&amp;gt;&lt;br /&gt;
                  &amp;lt;%= check_box_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][iscorrect]&amp;quot;,'1', @quiz_question_choice.iscorrect) %&amp;gt;&lt;br /&gt;
                  &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceCheckbox][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;MultipleChoiceRadio&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][correctindex]&amp;quot;, &amp;quot;#{i}&amp;quot;, @quiz_question_choice.iscorrect)%&amp;gt;&lt;br /&gt;
                &amp;amp;nbsp;&amp;lt;%= text_field_tag &amp;quot;quiz_question_choices[#{questionnum}][MultipleChoiceRadio][#{i}][txt]&amp;quot;, @quiz_question_choice.txt, :size=&amp;gt;40 %&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
              &amp;lt;%if @question.type==&amp;quot;TrueFalse&amp;quot; %&amp;gt;&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;True&amp;quot;%&amp;gt;&lt;br /&gt;
                  &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'True', @quiz_question_choice.iscorrect) %&amp;gt;   True&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
                &amp;lt;% if @quiz_question_choice.txt==&amp;quot;False&amp;quot;%&amp;gt;&lt;br /&gt;
                    &amp;lt;%= radio_button_tag(&amp;quot;quiz_question_choices[#{questionnum}][TrueFalse][1][iscorrect]&amp;quot;, 'False', @quiz_question_choice.iscorrect) %&amp;gt;   False&lt;br /&gt;
                &amp;lt;%end%&amp;gt;&lt;br /&gt;
              &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;/tr&amp;gt;&lt;br /&gt;
          &amp;lt;% i+=1 %&amp;gt;&lt;br /&gt;
        &amp;lt;%end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt; &lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After refactoring, the same file looked like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;% if @questionnaire.type == 'QuizQuestionnaire' %&amp;gt;&lt;br /&gt;
  &amp;lt;!--handle a questionnaire differently if it is a quiz--&amp;gt;&lt;br /&gt;
    &amp;lt;table id=&amp;quot;questions_table&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;% if $disp_flag != 1 %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td align=left width=300&amp;gt;Questions:&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;%  if @questionnaire.type != 'QuizQuestionnaire' %&amp;gt;&amp;lt;td align=left&amp;gt;weight&amp;lt;/td&amp;gt;&amp;lt;%end%&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
      &amp;lt;% for @question in @questionnaire.questions %&amp;gt;&lt;br /&gt;
      &amp;lt;% i=1 %&amp;gt;&lt;br /&gt;
         &amp;lt;%= @question.edit(i) %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/table&amp;gt;&lt;br /&gt;
  &amp;lt;% end %&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Refactoring complete ==&lt;br /&gt;
Logic is written in multiple_choice_checkbox model for multiple choice checkbox question type. Similarly, same process is followed for remaining question types. Now, to begin a quiz, complete method is called from the model.&lt;br /&gt;
     @question = self&lt;br /&gt;
     html = &amp;quot;&amp;quot;&lt;br /&gt;
     html += label_tag(&amp;quot;#{question.id}&amp;quot;, question.txt) +&amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
     quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id)&lt;br /&gt;
     quiz_question_choices.each do |choice|&lt;br /&gt;
       if answer==&amp;quot;view&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;, choice.iscorrect)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       if answer==&amp;quot;take&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       html.html_safe&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Refactoring view_completed_question ==&lt;br /&gt;
The logic for viewing completed question and their answers is written in app/views/student_quizzes/finished_quiz.html.erb using a redundant if-elsif structure as shown below. &amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;% if question_type.eql? 'MultipleChoiceRadio' %&amp;gt;&lt;br /&gt;
    &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |answer|  %&amp;gt;&lt;br /&gt;
      &amp;lt;% if(answer.iscorrect) %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt;&amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;/b&amp;gt; -- Correct &amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;%else%&amp;gt;&lt;br /&gt;
        &amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id).first%&amp;gt;&lt;br /&gt;
    Your answer is: &amp;lt;b&amp;gt;&amp;lt;%= user_answer.comments  %&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
    &amp;lt;%if user_answer.answer==1%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%else%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%end%&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;% elsif question_type.eql? 'MultipleChoiceCheckbox' %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;% elsif(question_type == 'TrueFalse') %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
The app/views/student_quizzes/finished_quiz.html.erb was refactored by removing the logic from the view and making it clean. We used a single construct which determines question type and answer type by calling view_completed_question method declared in quiz class as shown below.&lt;br /&gt;
 &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;b&amp;gt;Question &amp;lt;%= i %&amp;gt;: &amp;lt;/b&amp;gt;&amp;lt;%= label_tag &amp;quot;#{question.id}&amp;quot;, question.txt %&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;%= question.view_completed_question(i,user_answer) %&amp;gt;&lt;br /&gt;
 &amp;lt;% i += 1 %&amp;gt;&lt;br /&gt;
Similarly, logic was written in models for each of the question types. Following code snippet shows view_completed_question for true/false question type.&lt;br /&gt;
def view_completed_question(count, answer)&lt;br /&gt;
     @question = self&lt;br /&gt;
     html=&amp;quot;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Correct Answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= QuizQuestionChoice.where(question_id: @question.id,iscorrect: 1).first.txt&lt;br /&gt;
     html+= &amp;quot;&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Your answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= answer.first.coments + &amp;quot;&amp;lt;/b&amp;gt;&amp;quot;&lt;br /&gt;
     if(answer.first.answer == 1)&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/Check-icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/delete_icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
     html+= &amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Remove irrelevant comments from the student_quizzes_controller ====&lt;br /&gt;
The student_quizzes_controller has a few comments which are irrelevant and make the method bulky. These could be safely removed from the code.&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101177</id>
		<title>CSC/ECE 517 Spring 2016/Refactor different question types from quiz feature</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature&amp;diff=101177"/>
		<updated>2016-03-24T00:22:26Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added section for 'view_question_text'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This wiki page is for the description of changes made under E1602 OSS assignment for Spring 2016, CSC/ECE 517.&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
====Background====&lt;br /&gt;
&lt;br /&gt;
Expertiza is an open source project based on Ruby on Rails framework. Expertiza has a quizzing feature which allow student authors to create quiz questions and test the peer reviewers. The idea behind this is, if a reviewer can answer the quiz questions which were created by the author correctly, we assume that the reviewer has read the artifact carefully enough and thereby we trust the peer-review.&lt;br /&gt;
&lt;br /&gt;
====Current Implementation and Problems====&lt;br /&gt;
* Following three different types of questions are supported in quizzing feature of Expertiza&lt;br /&gt;
# Multiple Choice Radio&lt;br /&gt;
# Multiple Choice Checkbox&lt;br /&gt;
# True/False&lt;br /&gt;
* The current implementation of Quizzing feature is not consistent with the current questions and questionnaires. Since Quiz questionnaire is one sub type of questionnaire, so it should follow the design of other type of questionnaires. But, the current implementation is inconsistent with other questionnaires.&lt;br /&gt;
* In order to create a quiz, the existing code is written in the views which has a series of if-then structures to implement the functionality of each different question type. This kind of implementation makes the code slower and violates the principles of MVC architecture.&lt;br /&gt;
* Current HTML code doesn't looks like source code.&lt;br /&gt;
* Code is repeated for different question types.&lt;br /&gt;
* Proper Ruby naming conventions are not followed&lt;br /&gt;
====Changes Implemented====&lt;br /&gt;
* All logic moved to model. Four separate methods - 'edit', 'view_question_text', 'complete' and 'view_completed_question' in order to generate the same html code for each of the question types. We used polymorphism by declaring all these methods in QuizQuestion class which inherits from Questions class and has sub-types MultipleChoiceRadio, MultipleChoiceCheckbox, and TrueFalse. &lt;br /&gt;
* When questionnaire author creates a quiz, 'edit' method is called. To call this on UI, you can login as a student, click 'create quiz' / 'edit quiz' on 'Your Works' page. The 'edit' method is now called from /view/questionnaires/_quiz_question.html.erb&lt;br /&gt;
* When questions are viewed by the author or the instructor, 'view_question_text' method is called. To call this on UI, you can either login as a student, click 'view quiz' on 'Ypur works' page or login as an instructor, find an assignment with quizzing feature and click the icon 'view quiz questions'. The 'view_question_text' calls view/questionnaires/view.html.erb&lt;br /&gt;
&lt;br /&gt;
* When the quiz takers tries to take the quiz, “complete” is called. To call this on UI, you can login as a quiz taker, request a quiz to take on “Take quizzes” page, then click “begin”. This method is now called on “view/student_quizzes/take_quiz”.&lt;br /&gt;
* When the quiz taker finished taking a quiz and wants to view the quiz result again,  “view_completed_question” is called. To call this on UI, you can login as a quiz taker, find a finished quiz and click “view”. This method is called on “view/student_quizzes/finished_quiz”.&lt;br /&gt;
* Using polymorphism and DRY principles, code repetition has been eliminated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;view_question_text&amp;lt;/tt&amp;gt; method is called when the author of the quiz or the instructor views the quiz. The method is responsible for generating the HTML to display the question along with each of its choices. The correct choice(s) should be bolded. Prior to refactoring, this functionality was located in &amp;lt;tt&amp;gt;app/views/student_quizzes/review_questions.html.erb&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;% questions.each do |question| %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt; &amp;lt;%= question.txt %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
        &amp;lt;% question_type = question.get_formatted_question_type%&amp;gt;&lt;br /&gt;
        Question Type: &amp;lt;%= question_type %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;% if question_type == 'True/False' %&amp;gt;&lt;br /&gt;
          Correct Answer: &amp;lt;%= (QuizQuestionChoice.where(question_id: question.id, iscorrect:1).first.txt) %&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Radio' %&amp;gt;&lt;br /&gt;
          &amp;lt;% correct_answer = '' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% elsif question_type == 'Multiple Choice - Checked' %&amp;gt;&lt;br /&gt;
          Answer Options:&amp;lt;br&amp;gt;&lt;br /&gt;
          &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |choice| %&amp;gt;&lt;br /&gt;
            &amp;lt;% if choice.iscorrect == true  %&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;B&amp;gt;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;/B&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;%else%&amp;gt;&lt;br /&gt;
              &amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;%= choice.txt %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
        &amp;lt;% end %&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This logic has been moved to &amp;lt;tt&amp;gt;app/models/quiz_question.rb&amp;lt;/tt&amp;gt;, so now the view simply needs to call the method:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;%questions = questionnaire.questions%&amp;gt;&lt;br /&gt;
      &amp;lt;%questions.each do |question| %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
        &amp;lt;%if question.is_a? Question%&amp;gt;&lt;br /&gt;
          &amp;lt;%=question.view_question_text.html_safe%&amp;gt;&lt;br /&gt;
        &amp;lt;%end%&amp;gt;&lt;br /&gt;
        &lt;br /&gt;
      &amp;lt;% end %&amp;gt;&amp;lt;hr&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Unit tests were added to &amp;lt;tt&amp;gt;spec/models/quiz_question_spec.rb&amp;lt;/tt&amp;gt; covering all three types of questions to ensure that the correct HTML is generated.&lt;br /&gt;
&lt;br /&gt;
== Refactoring complete ==&lt;br /&gt;
Logic is written in multiple_choice_checkbox model for multiple choice checkbox question type. Similarly, same process is followed for remaining question types. Now, to begin a quiz, complete method is called from the model.&lt;br /&gt;
     @question = self&lt;br /&gt;
     html = &amp;quot;&amp;quot;&lt;br /&gt;
     html += label_tag(&amp;quot;#{question.id}&amp;quot;, question.txt) +&amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
     quiz_question_choices = QuizQuestionChoice.where(question_id: @question.id)&lt;br /&gt;
     quiz_question_choices.each do |choice|&lt;br /&gt;
       if answer==&amp;quot;view&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;, choice.iscorrect)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       if answer==&amp;quot;take&amp;quot;&lt;br /&gt;
         html += check_box_tag (&amp;quot;#{question.id}[]&amp;quot;, &amp;quot;#{choice.txt}&amp;quot;)&lt;br /&gt;
         html += label_tag(&amp;quot;#{choice.txt}&amp;quot;, choice.txt) + &amp;quot;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
       end&lt;br /&gt;
       html.html_safe&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
== Refactoring view_completed_question ==&lt;br /&gt;
The logic for viewing completed question and their answers is written in app/views/student_quizzes/finished_quiz.html.erb using a redundant if-elsif structure as shown below. &amp;lt;syntaxhighlight lang=&amp;quot;ruby&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;% if question_type.eql? 'MultipleChoiceRadio' %&amp;gt;&lt;br /&gt;
    &amp;lt;% QuizQuestionChoice.where(question_id: question.id).each do |answer|  %&amp;gt;&lt;br /&gt;
      &amp;lt;% if(answer.iscorrect) %&amp;gt;&lt;br /&gt;
        &amp;lt;b&amp;gt;&amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;/b&amp;gt; -- Correct &amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;%else%&amp;gt;&lt;br /&gt;
        &amp;lt;%= p answer.txt  %&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id).first%&amp;gt;&lt;br /&gt;
    Your answer is: &amp;lt;b&amp;gt;&amp;lt;%= user_answer.comments  %&amp;gt;&amp;lt;/b&amp;gt;&lt;br /&gt;
    &amp;lt;%if user_answer.answer==1%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/Check-icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%else%&amp;gt;&lt;br /&gt;
      &amp;lt;img src=&amp;quot;/assets/delete_icon.png&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;%end%&amp;gt;&lt;br /&gt;
    &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
    &amp;lt;% elsif question_type.eql? 'MultipleChoiceCheckbox' %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
    &amp;lt;% elsif(question_type == 'TrueFalse') %&amp;gt;&lt;br /&gt;
    ...&lt;br /&gt;
The app/views/student_quizzes/finished_quiz.html.erb was refactored by removing the logic from the view and making it clean. We used a single construct which determines question type and answer type by calling view_completed_question method declared in quiz class as shown below.&lt;br /&gt;
 &amp;lt;%user_answer=Answer.where(response_id: @response.id, question_id:  question.id)%&amp;gt;&lt;br /&gt;
 &amp;lt;b&amp;gt;Question &amp;lt;%= i %&amp;gt;: &amp;lt;/b&amp;gt;&amp;lt;%= label_tag &amp;quot;#{question.id}&amp;quot;, question.txt %&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;%= question.view_completed_question(i,user_answer) %&amp;gt;&lt;br /&gt;
 &amp;lt;% i += 1 %&amp;gt;&lt;br /&gt;
Similarly, logic was written in models for each of the question types. Following code snippet shows view_completed_question for true/false question type.&lt;br /&gt;
def view_completed_question(count, answer)&lt;br /&gt;
     @question = self&lt;br /&gt;
     html=&amp;quot;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Correct Answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= QuizQuestionChoice.where(question_id: @question.id,iscorrect: 1).first.txt&lt;br /&gt;
     html+= &amp;quot;&amp;lt;/b&amp;gt;&amp;lt;br/&amp;gt;&amp;quot;&lt;br /&gt;
     html+= &amp;quot;Your answer is: &amp;lt;b&amp;gt;&amp;quot;&lt;br /&gt;
     html+= answer.first.coments + &amp;quot;&amp;lt;/b&amp;gt;&amp;quot;&lt;br /&gt;
     if(answer.first.answer == 1)&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/Check-icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       html+= &amp;quot;&amp;lt;img src=/assets/delete_icon.png/&amp;gt;&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
     html+= &amp;quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
==== Remove irrelevant comments from the student_quizzes_controller ====&lt;br /&gt;
The student_quizzes_controller has a few comments which are irrelevant and make the method bulky. These could be safely removed from the code.&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016&amp;diff=101168</id>
		<title>CSC/ECE 517 Spring 2016</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2016&amp;diff=101168"/>
		<updated>2016-03-23T23:05:23Z</updated>

		<summary type="html">&lt;p&gt;Jesankar: Added link for the &amp;quot;Refactor different question types from quiz feature&amp;quot; project&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Calibration Assignment Submissions==&lt;br /&gt;
*[[Calibration Assignment Submission (OmniAuth)]]&lt;br /&gt;
*[[Calibration Assignment Submission (Patch_verb)]]&lt;br /&gt;
&lt;br /&gt;
==Writing Assignment 2==&lt;br /&gt;
[[CSC/ECE 517 Spring 2016/Mozilla Implement HTML5 form validation]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring 2016/Functional Tests for Questionnaire Controller]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring 2016 / Expertiza Self-Review Feature]]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Spring 2016/Refactor different question types from quiz feature]]&lt;/div&gt;</summary>
		<author><name>Jesankar</name></author>
	</entry>
</feed>