<?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=Cbritt</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=Cbritt"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Cbritt"/>
	<updated>2026-05-12T14:22:45Z</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_2023_-_E2320._Reimplement_the_Question_Hierarchy&amp;diff=150246</id>
		<title>CSC/ECE 517 Spring 2023 - E2320. Reimplement the Question Hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_Hierarchy&amp;diff=150246"/>
		<updated>2023-04-27T15:31:27Z</updated>

		<summary type="html">&lt;p&gt;Cbritt: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The current implementation of the question hierarchy is not very clean and contains confusing variable and method names. Also, many methods in the model classes return long HTML strings which are difficult to read. The goal of this project is to reimplement this part of the application to make it more readable, understandable and maintainable. This includes cleaning up the existing classes&lt;br /&gt;
&lt;br /&gt;
===Explanation of Feature===&lt;br /&gt;
The Question class and its sub-classes are used to implement all rubric items, quiz questions, and survey questions in Expertiza. For example, a professor could use this feature to make up a questionnaire for their class. There are 3 main types of questions in Experitza: scored, unscored, and upload file.&lt;br /&gt;
&lt;br /&gt;
Below is a written explanation of the hierarchy. For a visual reference, refer to the [[#UML Diagram]]:&lt;br /&gt;
&lt;br /&gt;
'''1. Choice question''' are types of questions that give the user a list of answers to choose from. It is broken into two subcategories: scored and unscored.&lt;br /&gt;
* '''Scored questions''' are questions that are assigned a point value and contribute to the final score of the questionnaire.&lt;br /&gt;
** Scale - a set of answer options that typically cover a range of opinions, e.g. Agree, Neither agree nor disagree, Disagree, etc.&lt;br /&gt;
** Criterion - a standard for judging something,&lt;br /&gt;
* '''Unscored questions''' are questions that do not contribute to the final score of the questionnaire.&lt;br /&gt;
** Dropdown - list of options displayed in a dropdown menu.&lt;br /&gt;
** Multiple Choice - presents multiple options from a list of possible answers and can be single select (radio buttons) or multi-select (check boxes).&lt;br /&gt;
** Check Box - allows multiple selections from a list of options.&lt;br /&gt;
&lt;br /&gt;
'''2. Text Response''' allows the user to type in their answer instead of choosing from a list of answer options.&lt;br /&gt;
* Text Area - text box which has a height and width associated with it that can be adjusted.&lt;br /&gt;
* Text Field - 1 input line that does not change shape.&lt;br /&gt;
&lt;br /&gt;
'''3. Upload File'''&lt;br /&gt;
The upload file option allows the user to upload a file with valid input to use as a questionnaire (as the name suggests). The user can also export the questionnaire to a .csv file.&lt;br /&gt;
&lt;br /&gt;
===Goals===&lt;br /&gt;
Our goals for reimplementation and to improve the code:&lt;br /&gt;
* Improve variables and methods names to give accurate representation of their functionality.&lt;br /&gt;
* Include comments for further clarification.&lt;br /&gt;
* Implement partials to deal with the HTML strings - this will DRY up the code.&lt;br /&gt;
* Add RSpec test cases - ensure existing tests work and add more where applicable.&lt;br /&gt;
&lt;br /&gt;
===Design Goals===&lt;br /&gt;
'''1. Update code comments'''&lt;br /&gt;
&lt;br /&gt;
Some methods and classes had little to no comments before this project, and any existing comments were not in depth enough to give proper context for functionality. One of our design goals is to write more in depth comments that better explain functionality for the code. &lt;br /&gt;
&lt;br /&gt;
'''2. DRY out code with partials'''&lt;br /&gt;
&lt;br /&gt;
Another one of our design goals is to implement additional partials for the question types. For program 3 we started adding partials by looking at the similarities between all three question types and pulling out the similarities into partials which we stored in [https://github.com/pparghod/reimplementation-back-end/tree/main/app/views 'app/views']. Then we made calls to these partials from within each subclass. An example of a partial we created can be seen [https://github.com/pparghod/reimplementation-back-end/blob/main/app/views/questionnaire/edit/_edit_dropdown.erb here], where we made a partial for code that displays an edit input for dropdown questions. Thanks to this partial, in the future if we ever need to call this code again we can just [https://github.com/pparghod/reimplementation-back-end/blob/20093dcb23750c94a9c32803914e1506c9ae556e/app/models/dropdown.rb#L7 call the partial], reducing the number of lines of code and reducing redundancy.  &lt;br /&gt;
&lt;br /&gt;
'''3. Controllers'''&lt;br /&gt;
&lt;br /&gt;
The controllers to be implemented are questionnaires_controller.rb and questions_controller.rb. In the previous implementation of questionnaires_controller.rb, it contained several functions which will be moved to questions_controller.rb because they specifically pertain to questions and not the questionnaire. The questions controller will store all of the partials we have made so far and any additional partials we need to create. This will keep all the partials in one central location and DRY out the code to follow better design. &lt;br /&gt;
&lt;br /&gt;
See [[#Model-Controller Diagram]] for the model and controller design.&lt;br /&gt;
&lt;br /&gt;
The following functions have been moved from questionnaires_controller.rb to questions_controller.rb:&lt;br /&gt;
 add_new_questions()&lt;br /&gt;
 save_all_questions()&lt;br /&gt;
 save_new_questions()&lt;br /&gt;
 delete_questions()&lt;br /&gt;
 save_questions()&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
====Question Hierarchy====&lt;br /&gt;
Below is a diagram showing the overall Question hierarchy to better give an idea of it's structure. (Click on the image to zoom in.) &lt;br /&gt;
&lt;br /&gt;
[[File:E2320-UML.png|1200px]]&lt;br /&gt;
&lt;br /&gt;
====Model-Controller Diagram====&lt;br /&gt;
Below is a model dependency diagram including the controllers. (Click on the image to zoom in.) &lt;br /&gt;
&lt;br /&gt;
[[File:E2320-model-controller-dependency-diagram.png|1100px]]&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
===RSpec===&lt;br /&gt;
&lt;br /&gt;
We reimplemented the test cases to match the changes we've made to the question-related models. One of the primary goals we had were to make sure that the existing tests still passed. Several tests were removed for the edit methods in a few of the models (such as checkbox_spec.rb and dropdown_spec.rb) because those methods were replaced with partials. Partials have not been fully implemented which is why we did not include tests for them. However, this is something that should be revisited in the future.&lt;br /&gt;
&lt;br /&gt;
Several components we tested for are:&lt;br /&gt;
* Test that the question was completed&lt;br /&gt;
* Test that the question input is valid&lt;br /&gt;
* Test that the question text can be viewed&lt;br /&gt;
* Test if the correct question text is viewed by an instructor or a student&lt;br /&gt;
* Test if the instructor added in a column header, section header or table header and that it was completed&lt;br /&gt;
* Test that the alternatives were completed&lt;br /&gt;
&lt;br /&gt;
Given below is an example of the tests we've written:&lt;br /&gt;
 describe Dropdown do&lt;br /&gt;
  let!(:dropdown) { Dropdown.create(id: 4, type: 'Dropdown', seq: 4.0, txt: 'Test text', weight: 13) }&lt;br /&gt;
  let!(:answer) { Answer.create(id: 1, question_id: 4, questionnaire_type_id: 1, answer: 1, comments: &amp;quot;Test comment&amp;quot;) }&lt;br /&gt;
  describe '#view_question_text' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      html = dropdown.view_question_text&lt;br /&gt;
      expect(html).to eq('&amp;lt;TR&amp;gt;&amp;lt;TD align=&amp;quot;left&amp;quot;&amp;gt; Test text &amp;lt;/TD&amp;gt;&amp;lt;TD align=&amp;quot;left&amp;quot;&amp;gt;Dropdown&amp;lt;/TD&amp;gt;&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;13&amp;lt;/TD&amp;gt;&amp;lt;TD align=&amp;quot;center&amp;quot;&amp;gt;&amp;amp;mdash;&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#view_completed_question' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      html = dropdown.view_completed_question(1, answer)&lt;br /&gt;
      expect(html).to eq('&amp;lt;nowiki&amp;gt;&amp;lt;b&amp;gt;&amp;lt;/nowiki&amp;gt;1. Test text&amp;lt;nowiki&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;amp;nbsp&amp;amp;nbsp&amp;amp;nbsp&amp;amp;nbspTest comment')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#complete_for_alternatives' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      alternatives = ['Alternative 1', 'Alternative 2', 'Alternative 3']&lt;br /&gt;
      html = dropdown.complete_for_alternatives(alternatives, answer)&lt;br /&gt;
      expect(html).to eq('&amp;lt;option value=&amp;quot;Alternative 1&amp;quot;&amp;gt;Alternative 1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;Alternative 2&amp;quot;&amp;gt;Alternative 2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;Alternative 3&amp;quot;&amp;gt;Alternative 3&amp;lt;/option&amp;gt;')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#complete' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      alternatives = ['Alternative 1|Alternative 2|Alternative 3']&lt;br /&gt;
      allow(dropdown).to receive(:alternatives).and_return(alternatives)&lt;br /&gt;
      allow(dropdown).to receive(:complete_for_alternatives).and_return('')&lt;br /&gt;
      html = dropdown.complete(1, answer)&lt;br /&gt;
      &amp;lt;nowiki&amp;gt;expect(html).to eq('&amp;lt;p style=&amp;quot;width: 80%;&amp;quot;&amp;gt;&amp;lt;label for=&amp;quot;responses_1&amp;quot;&amp;quot;&amp;gt;Test text&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/label&amp;gt;'&lt;br /&gt;
      + '&amp;lt;input id=&amp;quot;responses_1_score&amp;quot; name=&amp;quot;responses[1][score]&amp;quot; type=&amp;quot;hidden&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;min-width: 100px;&amp;quot;&amp;gt;'&lt;br /&gt;
      + '&amp;lt;select id=&amp;quot;responses_1_comments&amp;quot; label=Test text name=&amp;quot;responses[1][comment]&amp;quot;&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/p&amp;gt;')&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Given below is the full list of tests:&lt;br /&gt;
&lt;br /&gt;
[[File:E2320-RSpec.png]]&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
===Tasks Completed===&lt;br /&gt;
The table below highlights the work we have completed so far:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! File !! Changes Made !! Test&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|questionnaires_controller.rb&lt;br /&gt;
|&lt;br /&gt;
*Moved several functions to questions_controllers.rb&lt;br /&gt;
*Updated comments for further clarification&lt;br /&gt;
|&lt;br /&gt;
TBA&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|questions_controller.rb&lt;br /&gt;
|&lt;br /&gt;
*Implemented functions from questionnaires_controller.rb&lt;br /&gt;
*Updated comments for further clarification&lt;br /&gt;
|&lt;br /&gt;
TBA&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/checkbox.rb checkbox.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial&lt;br /&gt;
*Added comments - Provided functionality detail in the comments for all methods&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/checkbox_spec.rb Created RSpec testing for all method]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/criterion.rb criterion.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial &lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/criterion_spec.rb Created RSpec testing for all method, and different question scenarios]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/dropdown.rb dropdown.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial &lt;br /&gt;
*Added comments - none existed previously&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/dropdown_spec.rb RSpec test - tests 4 methods]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/multiple_choice_checkbox.rb multiple_choice_checkbox.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial &lt;br /&gt;
*Updated comments - more details in how all functions work&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/multiple_choice_checkbox_spec.rb RSpec test - all methods and different # of boxes selected]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/multiple_choice_radio.rb multiple_choice_radio.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial &lt;br /&gt;
*Updated comments - more details in how all functions work&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/multiple_choice_radio_spec.rb RSpec test - different tests to make sure valid questions can be created]&lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/scale.rb scale.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial &lt;br /&gt;
*Updated comments - more details in how all functions work&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/scale_spec.rb RSpec test - tests all methods]&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/text_area.rb text_area.rb]&lt;br /&gt;
|&lt;br /&gt;
*Added partial to 'complete' method&lt;br /&gt;
*Added comments - none existed previously&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/text_area_spec.rb RSpec test - tests all methods]&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/text_field.rb text_field.rb]&lt;br /&gt;
|&lt;br /&gt;
*Added partial to 'complete' method&lt;br /&gt;
*Added comments - none existed previously&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/text_field_spec.rb RSpec test - tests all methods]&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/upload_file.rb upload_file.rb]&lt;br /&gt;
|&lt;br /&gt;
*Added comments - none existed previously&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/upload_file.rb RSpec test - tests 2 methods]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Given below is an example of the comments we've added to clarify what the methods are doing, because the method name alone can be confusing. In the example below, the name 'complete_first_second_input' might not be intuitive for someone unfamiliar with the code. The added comments provide more insight into what will be displayed for each method.&lt;br /&gt;
&lt;br /&gt;
From [https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/checkbox.rb checkbox.rb]:&lt;br /&gt;
&lt;br /&gt;
  '''# Returns what to display for the first and second inputs (comments and scores).'''&lt;br /&gt;
  def complete_first_second_input(count, answer = nil)&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  '''# Returns what to display for the third input (the checkbox itself).'''&lt;br /&gt;
  def complete_third_input(count, answer = nil)&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  '''# Create the executable script for client-side interaction on the checkbox'''&lt;br /&gt;
  def complete_script(count)&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Overall, we met our goals of adding comments and improving the names of methods and variables to make the code easily understandable to the user. We implemented several partials to handle the HTML strings and added RSpec test cases. We cleaned up the unused comments/code to make the code readable and understandable.&lt;br /&gt;
&lt;br /&gt;
===Next Steps===&lt;br /&gt;
In the future, we would like to fully implement partials and thoroughly test them. We believe partials will improve the code by making it more readable and reusable. Then we would like to get our code ready to merge into Expertiza.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
* Prof. Edward F. Gehringer&lt;br /&gt;
* Priyam Garg&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Colleen Britt&lt;br /&gt;
* Kimberly Jones&lt;br /&gt;
* Priyanka Arghode&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://stackoverflow.com/questions/3425971/organizing-partials-for-a-polymorphic-resource Organizing Partials]&lt;br /&gt;
#[https://www.amberbit.com/blog/2011/12/27/render-views-and-partials-outside-controllers-in-rails-3 Render Views and Partials Outside Controllers]&lt;br /&gt;
#[https://github.com/pparghod/reimplementation-back-end Github Repo]&lt;br /&gt;
#[https://github.com/expertiza/reimplementation-back-end/pull/10 Link to initial pull request]&lt;br /&gt;
#[https://github.com/users/pparghod/projects/2/views/1 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Cbritt</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_Hierarchy&amp;diff=149692</id>
		<title>CSC/ECE 517 Spring 2023 - E2320. Reimplement the Question Hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_Hierarchy&amp;diff=149692"/>
		<updated>2023-04-13T02:06:57Z</updated>

		<summary type="html">&lt;p&gt;Cbritt: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Design Doc&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The current implementation of the question hierarchy is not very clean and contains confusing variable and method names. Also, many methods in the model classes return long HTML strings which are difficult to read. The goal of this project is to reimplement this part of the application to make it more readable, understandable and maintainable. This includes cleaning up the existing classes&lt;br /&gt;
&lt;br /&gt;
===Explanation of Feature===&lt;br /&gt;
The Question class and its sub-classes are used to implement all rubric items, quiz questions, and survey questions in Expertiza. For example, a professor could use this feature to make up a questionnaire for their class. There are 3 main types of questions in Experitza: scored, unscored, and upload file.&lt;br /&gt;
&lt;br /&gt;
Below is a written explanation of the hierarchy. For a visual reference, refer to the [[#UML Diagram]]:&lt;br /&gt;
&lt;br /&gt;
'''1. Choice question''' are types of questions that give the user a list of answers to choose from. It is broken into two subcategories: scored and unscored.&lt;br /&gt;
* '''Scored questions''' are questions that are assigned a point value and contribute to the final score of the questionnaire.&lt;br /&gt;
** Scale - a set of answer options that typically cover a range of opinions, e.g. Agree, Neither agree nor disagree, Disagree, etc.&lt;br /&gt;
** Criterion - a standard for judging something,&lt;br /&gt;
* '''Unscored questions''' are questions that do not contribute to the final score of the questionnaire.&lt;br /&gt;
** Dropdown - list of options displayed in a dropdown menu.&lt;br /&gt;
** Multiple Choice - presents multiple options from a list of possible answers and can be single select (radio buttons) or multi-select (check boxes).&lt;br /&gt;
** Check Box - allows multiple selections from a list of options.&lt;br /&gt;
&lt;br /&gt;
'''2. Text Response''' allows the user to type in their answer instead of choosing from a list of answer options.&lt;br /&gt;
* Text Area - text box which has a height and width associated with it that can be adjusted.&lt;br /&gt;
* Text Field - 1 input line that does not change shape.&lt;br /&gt;
&lt;br /&gt;
'''3. Upload File'''&lt;br /&gt;
The upload file option allows the user to upload a file with valid input to use as a questionnaire (as the name suggests). The user can also export the questionnaire to a .csv file.&lt;br /&gt;
&lt;br /&gt;
===Goals===&lt;br /&gt;
Our goals for reimplementation and to improve the code:&lt;br /&gt;
* Improve variables and methods names to give accurate representation of their functionality.&lt;br /&gt;
* Include comments for further clarification.&lt;br /&gt;
* Implement partials to deal with the HTML strings - this will DRY up the code.&lt;br /&gt;
* Add RSpec test cases - ensure existing tests work and add more where applicable.&lt;br /&gt;
&lt;br /&gt;
===Design Goals===&lt;br /&gt;
'''1. Update code comments'''&lt;br /&gt;
&lt;br /&gt;
Some methods and classes had little to no comments before this project, and any existing comments were not in depth enough to give proper context for functionality. One of our design goals is to write more in depth comments that better explain functionality for the code. &lt;br /&gt;
&lt;br /&gt;
'''2. DRY out code with partials'''&lt;br /&gt;
&lt;br /&gt;
Another one of our design goals is to implement additional partials for the question types. For program 3 we started adding partials by looking at the similarities between all three question types and pulling out the similarities into partials which we stored in [https://github.com/pparghod/reimplementation-back-end/tree/main/app/views 'app/views']. Then we made calls to these partials from within each subclass. An example of a partial we created can be seen [https://github.com/pparghod/reimplementation-back-end/blob/main/app/views/questionnaire/edit/_edit_dropdown.erb here], where we made a partial for code that displays an edit input for dropdown questions. Thanks to this partial, in the future if we ever need to call this code again we can just [https://github.com/pparghod/reimplementation-back-end/blob/20093dcb23750c94a9c32803914e1506c9ae556e/app/models/dropdown.rb#L7 call the partial], reducing the number of lines of code and reducing redundancy.  &lt;br /&gt;
&lt;br /&gt;
'''3. Controllers'''&lt;br /&gt;
&lt;br /&gt;
The controllers to be implemented are questionnaires_controller.rb and questions_controller.rb. In the previous implementation of questionnaires_controller.rb, it contained several functions which will be moved to questions_controller.rb because they specifically pertain to questions and not the questionnaire. The questions controller will store all of the partials we have made so far and any additional partials we need to create. This will keep all the partials in one central location and DRY out the code to follow better design. &lt;br /&gt;
&lt;br /&gt;
See [[#Model-Controller Diagram]] for the model and controller design.&lt;br /&gt;
&lt;br /&gt;
The following functions have been moved from questionnaires_controller.rb to questions_controller.rb:&lt;br /&gt;
 add_new_questions()&lt;br /&gt;
 save_all_questions()&lt;br /&gt;
 save_new_questions()&lt;br /&gt;
 delete_questions()&lt;br /&gt;
 save_questions()&lt;br /&gt;
&lt;br /&gt;
=== UML Diagram ===&lt;br /&gt;
&lt;br /&gt;
====Question Hierarchy====&lt;br /&gt;
Below is a diagram showing the overall Question hierarchy to better give an idea of it's structure. (Click on the image to zoom in.) &lt;br /&gt;
&lt;br /&gt;
[[File:E2320-UML.png|1200px]]&lt;br /&gt;
&lt;br /&gt;
====Model-Controller Diagram====&lt;br /&gt;
Below is a model dependency diagram including the controllers. (Click on the image to zoom in.) &lt;br /&gt;
&lt;br /&gt;
[[File:E2320-model-controller-dependency-diagram.png|1100px]]&lt;br /&gt;
&lt;br /&gt;
== Test Plan ==&lt;br /&gt;
&lt;br /&gt;
===RSpec===&lt;br /&gt;
&lt;br /&gt;
We reimplemented the test cases to match the changes we've made to the question-related models. One of the primary goals we had were to make sure that the existing tests still passed. Several tests were removed for the edit methods in a few of the models (such as checkbox_spec.rb and dropdown_spec.rb) because those methods were replaced with partials. Partials have not been fully implemented which is why we did not include tests for them. However, this is something that should be revisited in the future.&lt;br /&gt;
&lt;br /&gt;
Several components we tested for are:&lt;br /&gt;
* Test that the question was completed&lt;br /&gt;
* Test that the question input is valid&lt;br /&gt;
* Test that the question text can be viewed&lt;br /&gt;
* Test if the correct question text is viewed by an instructor or a student&lt;br /&gt;
* Test if the instructor added in a column header, section header or table header and that it was completed&lt;br /&gt;
* Test that the alternatives were completed&lt;br /&gt;
&lt;br /&gt;
Given below is an example of the tests we've written:&lt;br /&gt;
 describe Dropdown do&lt;br /&gt;
  let!(:dropdown) { Dropdown.create(id: 4, type: 'Dropdown', seq: 4.0, txt: 'Test text', weight: 13) }&lt;br /&gt;
  let!(:answer) { Answer.create(id: 1, question_id: 4, questionnaire_type_id: 1, answer: 1, comments: &amp;quot;Test comment&amp;quot;) }&lt;br /&gt;
  describe '#view_question_text' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      html = dropdown.view_question_text&lt;br /&gt;
      expect(html).to eq('&amp;lt;TR&amp;gt;&amp;lt;TD align=&amp;quot;left&amp;quot;&amp;gt; Test text &amp;lt;/TD&amp;gt;&amp;lt;TD align=&amp;quot;left&amp;quot;&amp;gt;Dropdown&amp;lt;/TD&amp;gt;&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;13&amp;lt;/TD&amp;gt;&amp;lt;TD align=&amp;quot;center&amp;quot;&amp;gt;&amp;amp;mdash;&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#view_completed_question' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      html = dropdown.view_completed_question(1, answer)&lt;br /&gt;
      expect(html).to eq('&amp;lt;nowiki&amp;gt;&amp;lt;b&amp;gt;&amp;lt;/nowiki&amp;gt;1. Test text&amp;lt;nowiki&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;amp;nbsp&amp;amp;nbsp&amp;amp;nbsp&amp;amp;nbspTest comment')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#complete_for_alternatives' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      alternatives = ['Alternative 1', 'Alternative 2', 'Alternative 3']&lt;br /&gt;
      html = dropdown.complete_for_alternatives(alternatives, answer)&lt;br /&gt;
      expect(html).to eq('&amp;lt;option value=&amp;quot;Alternative 1&amp;quot;&amp;gt;Alternative 1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;Alternative 2&amp;quot;&amp;gt;Alternative 2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;Alternative 3&amp;quot;&amp;gt;Alternative 3&amp;lt;/option&amp;gt;')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#complete' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      alternatives = ['Alternative 1|Alternative 2|Alternative 3']&lt;br /&gt;
      allow(dropdown).to receive(:alternatives).and_return(alternatives)&lt;br /&gt;
      allow(dropdown).to receive(:complete_for_alternatives).and_return('')&lt;br /&gt;
      html = dropdown.complete(1, answer)&lt;br /&gt;
      &amp;lt;nowiki&amp;gt;expect(html).to eq('&amp;lt;p style=&amp;quot;width: 80%;&amp;quot;&amp;gt;&amp;lt;label for=&amp;quot;responses_1&amp;quot;&amp;quot;&amp;gt;Test text&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/label&amp;gt;'&lt;br /&gt;
      + '&amp;lt;input id=&amp;quot;responses_1_score&amp;quot; name=&amp;quot;responses[1][score]&amp;quot; type=&amp;quot;hidden&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;min-width: 100px;&amp;quot;&amp;gt;'&lt;br /&gt;
      + '&amp;lt;select id=&amp;quot;responses_1_comments&amp;quot; label=Test text name=&amp;quot;responses[1][comment]&amp;quot;&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/p&amp;gt;')&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Given below is the full list of tests:&lt;br /&gt;
&lt;br /&gt;
[[File:E2320-RSpec.png]]&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
===Tasks Completed===&lt;br /&gt;
The table below highlights the work we have completed so far:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 100%;&lt;br /&gt;
! &amp;amp;nbsp;#&amp;amp;nbsp; !! File !! Changes Made !! Test&lt;br /&gt;
|-&lt;br /&gt;
|1&lt;br /&gt;
|questionnaires_controller.rb&lt;br /&gt;
|&lt;br /&gt;
*Moved several functions to questions_controllers.rb&lt;br /&gt;
*Updated comments for further clarification&lt;br /&gt;
|&lt;br /&gt;
TBA&lt;br /&gt;
|-&lt;br /&gt;
|2&lt;br /&gt;
|questions_controller.rb&lt;br /&gt;
|&lt;br /&gt;
*Implemented functions from questionnaires_controller.rb&lt;br /&gt;
*Updated comments for further clarification&lt;br /&gt;
|&lt;br /&gt;
TBA&lt;br /&gt;
|-&lt;br /&gt;
|3&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/checkbox.rb checkbox.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial&lt;br /&gt;
*Added comments - Provided functionality detail in the comments for all methods&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/checkbox_spec.rb Created RSpec testing for all method]&lt;br /&gt;
|-&lt;br /&gt;
|4&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/criterion.rb criterion.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial &lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/criterion_spec.rb Created RSpec testing for all method, and different question scenarios]&lt;br /&gt;
|-&lt;br /&gt;
|5&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/dropdown.rb dropdown.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial &lt;br /&gt;
*Added comments - none existed previously&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/dropdown_spec.rb RSpec test - tests 4 methods]&lt;br /&gt;
|-&lt;br /&gt;
|6&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/multiple_choice_checkbox.rb multiple_choice_checkbox.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial &lt;br /&gt;
*Updated comments - more details in how all functions work&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/multiple_choice_checkbox_spec.rb RSpec test - all methods and different # of boxes selected]&lt;br /&gt;
|-&lt;br /&gt;
|7&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/multiple_choice_radio.rb multiple_choice_radio.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial &lt;br /&gt;
*Updated comments - more details in how all functions work&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/multiple_choice_radio_spec.rb RSpec test - different tests to make sure valid questions can be created]&lt;br /&gt;
|-&lt;br /&gt;
|8&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/scale.rb scale.rb]&lt;br /&gt;
|&lt;br /&gt;
*Replaced 'edit' method with partial &lt;br /&gt;
*Updated comments - more details in how all functions work&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/scale_spec.rb RSpec test - tests all methods]&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/text_area.rb text_area.rb]&lt;br /&gt;
|&lt;br /&gt;
*Added partial to 'complete' method&lt;br /&gt;
*Added comments - none existed previously&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/text_area_spec.rb RSpec test - tests all methods]&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/text_field.rb text_field.rb]&lt;br /&gt;
|&lt;br /&gt;
*Added partial to 'complete' method&lt;br /&gt;
*Added comments - none existed previously&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/text_field_spec.rb RSpec test - tests all methods]&lt;br /&gt;
|-&lt;br /&gt;
|11&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/upload_file.rb upload_file.rb]&lt;br /&gt;
|&lt;br /&gt;
*Added comments - none existed previously&lt;br /&gt;
|[https://github.com/pparghod/reimplementation-back-end/blob/main/spec/models/upload_file.rb RSpec test - tests 2 methods]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Given below is an example of the comments we've added to clarify what the methods are doing, because the method name alone can be confusing. In the example below, the name 'complete_first_second_input' might not be intuitive for someone unfamiliar with the code. The added comments provide more insight into what will be displayed for each method.&lt;br /&gt;
&lt;br /&gt;
From [https://github.com/pparghod/reimplementation-back-end/blob/main/app/models/checkbox.rb checkbox.rb]:&lt;br /&gt;
&lt;br /&gt;
  '''# Returns what to display for the first and second inputs (comments and scores).'''&lt;br /&gt;
  def complete_first_second_input(count, answer = nil)&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  '''# Returns what to display for the third input (the checkbox itself).'''&lt;br /&gt;
  def complete_third_input(count, answer = nil)&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  '''# Create the executable script for client-side interaction on the checkbox'''&lt;br /&gt;
  def complete_script(count)&lt;br /&gt;
     ...&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
Overall, we met our goals of adding comments and improving the names of methods and variables to make the code easily understandable to the user. We implemented several partials to handle the HTML strings and added RSpec test cases. We cleaned up the unused comments/code to make the code readable and understandable.&lt;br /&gt;
&lt;br /&gt;
===Next Steps===&lt;br /&gt;
In the future, we would like to fully implement partials and thoroughly test them. We believe partials will improve the code by making it more readable and reusable. Then we would like to get our code ready to merge into Expertiza.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
* Prof. Edward F. Gehringer&lt;br /&gt;
* Priyam Garg&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Colleen Britt&lt;br /&gt;
* Kimberly Jones&lt;br /&gt;
* Priyanka Arghode&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://stackoverflow.com/questions/3425971/organizing-partials-for-a-polymorphic-resource Organizing Partials]&lt;br /&gt;
#[https://www.amberbit.com/blog/2011/12/27/render-views-and-partials-outside-controllers-in-rails-3 Render Views and Partials Outside Controllers]&lt;br /&gt;
#[https://github.com/pparghod/reimplementation-back-end Github Repo]&lt;br /&gt;
#[https://github.com/expertiza/reimplementation-back-end/pull/10 Link to initial pull request]&lt;br /&gt;
#[https://github.com/users/pparghod/projects/2/views/1 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Cbritt</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2320-model-controller-dependency-diagram.png&amp;diff=149655</id>
		<title>File:E2320-model-controller-dependency-diagram.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2320-model-controller-dependency-diagram.png&amp;diff=149655"/>
		<updated>2023-04-13T01:18:30Z</updated>

		<summary type="html">&lt;p&gt;Cbritt: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cbritt</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_Hierarchy&amp;diff=149234</id>
		<title>CSC/ECE 517 Spring 2023 - E2320. Reimplement the Question Hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_Hierarchy&amp;diff=149234"/>
		<updated>2023-04-08T01:08:40Z</updated>

		<summary type="html">&lt;p&gt;Cbritt: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Design Doc&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The current implementation of the question hierarchy is not very clean and contains confusing variable and method names. Also, many methods return long HTML strings which are difficult to read. The goal of this project is to reimplement this part of the application to make it more readable, understandable and maintainable.&lt;br /&gt;
&lt;br /&gt;
===Explanation of Feature - Question Hierarchy===&lt;br /&gt;
The Question class and its sub-classes are used to implement all rubric items, quiz questions, and survey questions in Expertiza. For example, a professor could use this feature to make up a review quiz for their class. There are 3 main types of questions in Experitza: scored, unscored, and upload file.&lt;br /&gt;
&lt;br /&gt;
Here is the hierarchy:&lt;br /&gt;
&lt;br /&gt;
'''1. Choice question'''&lt;br /&gt;
* Scored question&lt;br /&gt;
** Scale&lt;br /&gt;
** Criterion&lt;br /&gt;
* Unscored question&lt;br /&gt;
** Dropdown&lt;br /&gt;
** Multiple Choice&lt;br /&gt;
** Check Box&lt;br /&gt;
'''2. Text Response'''&lt;br /&gt;
* Text Area&lt;br /&gt;
* Text Field&lt;br /&gt;
'''3. Upload File'''&lt;br /&gt;
&lt;br /&gt;
Choice questions are types of questions that give the quiz taker a list of answers to choose from. It is broken into two subcategories scored and unscored. Scored question will give a number value depending upon if a user clicks on a particular answer. The unscored questions don't have  a score associated with them and come in a few different styles. The answers could be presented in a dropdown menu which only shows the answer choices after the user clicks on the dropdown arrow and clicks on an answer. Multiple choice questions present all the answers choices with a selectable bubble beside them and allow the user to click on the bubble to indicate their answer. Checkboxes are similar to multiple choice in that they present all of the answer choices at once however, the user must click on a certain number of boxes beside the answers they think are correct.&lt;br /&gt;
&lt;br /&gt;
Text response questions are different in that they allow the user to actually type in their answer instead of just being provided answers. A text area question has a height and width associated with it that can be adjusted while a text field question is just 1 input line that does not change shape.&lt;br /&gt;
&lt;br /&gt;
The last type of question is upload file which allows the user to upload a file to use as a quiz (as the name suggests). This option allows a person to upload a pre-made quiz document to be which will be converted into a quiz. So, a professor could type up their quiz questions and answers in a text file then choose upload and have Expertiza convert it into a quiz for them.&lt;br /&gt;
&lt;br /&gt;
===Goals===&lt;br /&gt;
* Improved naming of variables and methods&lt;br /&gt;
* Included comments for further clarification&lt;br /&gt;
* Implemented partials to deal with the HTML strings&lt;br /&gt;
* Added RSpec test cases&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
Based on the feedback provided to us by both our mentors and also peer reviews our team has decided upon a few key design goals to work on for the continuation of our work into Program 4. These goals are outlined below.&lt;br /&gt;
&lt;br /&gt;
===Design Goals===&lt;br /&gt;
'''1. Update code comments'''&lt;br /&gt;
&lt;br /&gt;
Some methods and classes had little to no comments, and existing comments were not in depth enough to give proper context for functionality. One of our design goals is to write more in depth comments that better explain functionality for the code. &lt;br /&gt;
&lt;br /&gt;
The files listed below have been updated with new comments:&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*checkbox.rb &lt;br /&gt;
*criterion.rb&lt;br /&gt;
*dropdown.rb&lt;br /&gt;
*multiple_choice_checkbox.rb&lt;br /&gt;
*multiple_choice_radio.rb&lt;br /&gt;
*scale.rb&lt;br /&gt;
*text_area.rb&lt;br /&gt;
*text_field.rb&lt;br /&gt;
*text_response.rb&lt;br /&gt;
*upload_file.rb&lt;br /&gt;
&lt;br /&gt;
Given below is an example of the comments we've added to clarify what the methods are doing because the method name alone can be confusing.&lt;br /&gt;
From checkbox.rb:&lt;br /&gt;
&lt;br /&gt;
  '''# Returns what to display for the first and second inputs (comments and scores).'''&lt;br /&gt;
  def complete_first_second_input(count, answer = nil)&lt;br /&gt;
    html = &amp;quot;&amp;lt;input id=\&amp;quot;responses_#{count.to_s}_comments\&amp;quot; name=\&amp;quot;responses[#{count.to_s}][comment]\&amp;quot; type=\&amp;quot;hidden\&amp;quot; value=\&amp;quot;\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
    html += &amp;quot;&amp;lt;input id=\&amp;quot;responses_#{count.to_s}_score\&amp;quot; name=\&amp;quot;responses[#{count.to_s}][score]\&amp;quot; type=\&amp;quot;hidden\&amp;quot;&amp;quot;&lt;br /&gt;
    html += if !answer.nil? &amp;amp;&amp;amp; (answer.answer == 1)&lt;br /&gt;
              'value=&amp;quot;1&amp;quot;'&lt;br /&gt;
            else&lt;br /&gt;
              'value=&amp;quot;0&amp;quot;'&lt;br /&gt;
            end&lt;br /&gt;
    html += '&amp;gt;'&lt;br /&gt;
    html&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  '''# Returns what to display for the third input (the checkbox itself).'''&lt;br /&gt;
  def complete_third_input(count, answer = nil)&lt;br /&gt;
    html = &amp;quot;&amp;lt;input id=\&amp;quot;responses_#{count.to_s}_checkbox\&amp;quot; type=\&amp;quot;checkbox\&amp;quot; onchange=\&amp;quot;checkbox#{count.to_s}Changed()\&amp;quot;&amp;quot;&lt;br /&gt;
    html += 'checked=&amp;quot;checked&amp;quot;' if !answer.nil? &amp;amp;&amp;amp; (answer.answer == 1)&lt;br /&gt;
    html += '&amp;gt;'&lt;br /&gt;
    html&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  '''# Create the executable script for client-side interaction on the checkbox'''&lt;br /&gt;
  def complete_script(count)&lt;br /&gt;
    html = &amp;quot;&amp;lt;script&amp;gt;function checkbox#{count.to_s}Changed() {&amp;quot;&lt;br /&gt;
    html += &amp;quot; var checkbox = jQuery(\&amp;quot;#responses_#{count.to_s}_checkbox\&amp;quot;);&amp;quot;&lt;br /&gt;
    html += &amp;quot; var response_score = jQuery(\&amp;quot;#responses_#{count.to_s}_score\&amp;quot;);&amp;quot;&lt;br /&gt;
    html += 'if (checkbox.is(&amp;quot;:checked&amp;quot;)) {'&lt;br /&gt;
    html += 'response_score.val(&amp;quot;1&amp;quot;);'&lt;br /&gt;
    html += '} else {'&lt;br /&gt;
    html += 'response_score.val(&amp;quot;0&amp;quot;);}}&amp;lt;/script&amp;gt;'&lt;br /&gt;
    html&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''2. DRY out code with partials'''&lt;br /&gt;
&lt;br /&gt;
Another one of our design goals is to implement additional partials for the question types. We added partials by looking at the similarities between all three question types and pull out the similarities into a new class.&lt;br /&gt;
*Ex: Question_Controller - Since all of the sub-categories inherit from the Question class we plan to make a question controller to hold all of the common functionality. One example of this can be seen with the method call 'edit' which exists in many of the subclasses like text_response.rb, text_area.rb, scale.rb, and criterion.rb. The partials will be moved into the question controller.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
&lt;br /&gt;
'''RSpec'''&lt;br /&gt;
&lt;br /&gt;
We reimplemented the test cases to match the changes we've made to the question-related models. Front-end testing wasn't necessary because our project doesn't involve changing any controller.&lt;br /&gt;
&lt;br /&gt;
The most notable models that were tested are:&lt;br /&gt;
 checkbox.rb &lt;br /&gt;
 criterion.rb&lt;br /&gt;
 dropdown.rb&lt;br /&gt;
 multiple_choice_checkbox.rb&lt;br /&gt;
 multiple_choice_radio.rb&lt;br /&gt;
 scale.rb&lt;br /&gt;
 text_area.rb&lt;br /&gt;
 text_field.rb&lt;br /&gt;
 text_response.rb&lt;br /&gt;
 upload_file.rb&lt;br /&gt;
&lt;br /&gt;
One of the primary goals we had were to make sure that the existing tests still passed. Several tests were removed for the edit methods in a few of the models (such as checkbox_spec.rb and dropdown_spec.rb) because those methods were replaced with partials. Partials have not been fully implemented which is why we did not include tests for them. However, this is something that should be revisited in the future.&lt;br /&gt;
&lt;br /&gt;
Given below is an example of the tests we've written:&lt;br /&gt;
 describe Dropdown do&lt;br /&gt;
  let!(:dropdown) { Dropdown.create(id: 4, type: 'Dropdown', seq: 4.0, txt: 'Test text', weight: 13) }&lt;br /&gt;
  let!(:answer) { Answer.create(id: 1, question_id: 4, questionnaire_type_id: 1, answer: 1, comments: &amp;quot;Test comment&amp;quot;) }&lt;br /&gt;
  describe '#view_question_text' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      html = dropdown.view_question_text&lt;br /&gt;
      expect(html).to eq('&amp;lt;TR&amp;gt;&amp;lt;TD align=&amp;quot;left&amp;quot;&amp;gt; Test text &amp;lt;/TD&amp;gt;&amp;lt;TD align=&amp;quot;left&amp;quot;&amp;gt;Dropdown&amp;lt;/TD&amp;gt;&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;13&amp;lt;/TD&amp;gt;&amp;lt;TD align=&amp;quot;center&amp;quot;&amp;gt;&amp;amp;mdash;&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#view_completed_question' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      html = dropdown.view_completed_question(1, answer)&lt;br /&gt;
      expect(html).to eq('&amp;lt;nowiki&amp;gt;&amp;lt;b&amp;gt;&amp;lt;/nowiki&amp;gt;1. Test text&amp;lt;nowiki&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;amp;nbsp&amp;amp;nbsp&amp;amp;nbsp&amp;amp;nbspTest comment')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#complete_for_alternatives' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      alternatives = ['Alternative 1', 'Alternative 2', 'Alternative 3']&lt;br /&gt;
      html = dropdown.complete_for_alternatives(alternatives, answer)&lt;br /&gt;
      expect(html).to eq('&amp;lt;option value=&amp;quot;Alternative 1&amp;quot;&amp;gt;Alternative 1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;Alternative 2&amp;quot;&amp;gt;Alternative 2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;Alternative 3&amp;quot;&amp;gt;Alternative 3&amp;lt;/option&amp;gt;')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#complete' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      alternatives = ['Alternative 1|Alternative 2|Alternative 3']&lt;br /&gt;
      allow(dropdown).to receive(:alternatives).and_return(alternatives)&lt;br /&gt;
      allow(dropdown).to receive(:complete_for_alternatives).and_return('')&lt;br /&gt;
      html = dropdown.complete(1, answer)&lt;br /&gt;
      &amp;lt;nowiki&amp;gt;expect(html).to eq('&amp;lt;p style=&amp;quot;width: 80%;&amp;quot;&amp;gt;&amp;lt;label for=&amp;quot;responses_1&amp;quot;&amp;quot;&amp;gt;Test text&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/label&amp;gt;'&lt;br /&gt;
      + '&amp;lt;input id=&amp;quot;responses_1_score&amp;quot; name=&amp;quot;responses[1][score]&amp;quot; type=&amp;quot;hidden&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;min-width: 100px;&amp;quot;&amp;gt;'&lt;br /&gt;
      + '&amp;lt;select id=&amp;quot;responses_1_comments&amp;quot; label=Test text name=&amp;quot;responses[1][comment]&amp;quot;&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/p&amp;gt;')&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Given below is the full list of tests:&lt;br /&gt;
&lt;br /&gt;
[[File:E2320-RSpec.png]]&lt;br /&gt;
&lt;br /&gt;
==Conclusions==&lt;br /&gt;
===Tasks Completed===&lt;br /&gt;
We met our goals of adding comments and improving the names of methods and variables to make the code easily understandable to the user. We implemented several partials to handle the HTML strings and added RSpec test cases.&lt;br /&gt;
===Next Steps===&lt;br /&gt;
In the future, we would like to fully implement partials and thoroughly test them. We believe partials will improve the code by making it more readable and reusable.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
* Prof. Edward F. Gehringer&lt;br /&gt;
* Priyam Garg&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Colleen Britt&lt;br /&gt;
* Kimberly Jones&lt;br /&gt;
* Priyanka Arghode&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://stackoverflow.com/questions/3425971/organizing-partials-for-a-polymorphic-resource Organizing Partials]&lt;br /&gt;
#[https://www.amberbit.com/blog/2011/12/27/render-views-and-partials-outside-controllers-in-rails-3 Render Views and Partials Outside Controllers]&lt;br /&gt;
#[https://github.com/pparghod/reimplementation-back-end Github Repo]&lt;br /&gt;
#[https://github.com/expertiza/reimplementation-back-end/pull/10 Link to initial pull request]&lt;br /&gt;
#[https://github.com/users/pparghod/projects/2/views/1 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Cbritt</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_Hierarchy&amp;diff=149226</id>
		<title>CSC/ECE 517 Spring 2023 - E2320. Reimplement the Question Hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_Hierarchy&amp;diff=149226"/>
		<updated>2023-04-08T00:59:56Z</updated>

		<summary type="html">&lt;p&gt;Cbritt: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Design Doc&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The current implementation of the question hierarchy is not very clean and contains confusing variable and method names. Also, many methods return long HTML strings which are difficult to read. The goal of this project is to reimplement this part of the application to make it more readable, understandable and maintainable.&lt;br /&gt;
&lt;br /&gt;
===Explanation of Feature - Question Hierarchy===&lt;br /&gt;
The Question class and its sub-classes are used to implement all rubric items, quiz questions, and survey questions in Expertiza. For example, a professor could use this feature to make up a review quiz for their class. There are 3 main types of questions in Experitza: scored, unscored, and upload file.&lt;br /&gt;
&lt;br /&gt;
Here is the hierarchy:&lt;br /&gt;
&lt;br /&gt;
'''1. Choice question'''&lt;br /&gt;
* Scored question&lt;br /&gt;
** Scale&lt;br /&gt;
** Criterion&lt;br /&gt;
* Unscored question&lt;br /&gt;
** Dropdown&lt;br /&gt;
** Multiple Choice&lt;br /&gt;
** Check Box&lt;br /&gt;
'''2. Text Response'''&lt;br /&gt;
* Text Area&lt;br /&gt;
* Text Field&lt;br /&gt;
'''3. Upload File'''&lt;br /&gt;
&lt;br /&gt;
Choice questions are types of questions that give the quiz taker a list of answers to choose from. It is broken into two subcategories scored and unscored. Scored question will give a number value depending upon if a user clicks on a particular answer. The unscored questions don't have  a score associated with them and come in a few different styles. The answers could be presented in a dropdown menu which only shows the answer choices after the user clicks on the dropdown arrow and clicks on an answer. Multiple choice questions present all the answers choices with a selectable bubble beside them and allow the user to click on the bubble to indicate their answer. Checkboxes are similar to multiple choice in that they present all of the answer choices at once however, the user must click on a certain number of boxes beside the answers they think are correct.&lt;br /&gt;
&lt;br /&gt;
Text response questions are different in that they allow the user to actually type in their answer instead of just being provided answers. A text area question has a height and width associated with it that can be adjusted while a text field question is just 1 input line that does not change shape.&lt;br /&gt;
&lt;br /&gt;
The last type of question is upload file which allows the user to upload a file to use as a quiz (as the name suggests). This option allows a person to upload a pre-made quiz document to be which will be converted into a quiz. So, a professor could type up their quiz questions and answers in a text file then choose upload and have Expertiza convert it into a quiz for them.&lt;br /&gt;
&lt;br /&gt;
===List of Work Done so Far===&lt;br /&gt;
The following list describes tasks that were accomplished:&lt;br /&gt;
* Improved naming of variables and methods&lt;br /&gt;
* Included comments for further clarification&lt;br /&gt;
* Implemented partials to deal with the HTML strings&lt;br /&gt;
* Added RSpec test cases&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
Based on the feedback provided to us by both our mentors and also peer reviews our team has decided upon a few key design goals to work on for the continuation of our work into Program 4. These goals are outlined below.&lt;br /&gt;
&lt;br /&gt;
===Design Goals===&lt;br /&gt;
'''1. Update code comments'''&lt;br /&gt;
&lt;br /&gt;
Some methods and classes had little to no comments, and existing comments were not in depth enough to give proper context for functionality. One of our design goals is to write more in depth comments that better explain functionality for the code. &lt;br /&gt;
&lt;br /&gt;
The files listed below have been updated with new comments:&lt;br /&gt;
*questionnaires_controller.rb&lt;br /&gt;
*checkbox.rb &lt;br /&gt;
*criterion.rb&lt;br /&gt;
*dropdown.rb&lt;br /&gt;
*multiple_choice_checkbox.rb&lt;br /&gt;
*multiple_choice_radio.rb&lt;br /&gt;
*scale.rb&lt;br /&gt;
*text_area.rb&lt;br /&gt;
*text_field.rb&lt;br /&gt;
*text_response.rb&lt;br /&gt;
*upload_file.rb&lt;br /&gt;
&lt;br /&gt;
Given below is an example of the comments we've added to clarify what the methods are doing because the method name alone can be confusing.&lt;br /&gt;
From checkbox.rb:&lt;br /&gt;
&lt;br /&gt;
  '''# Returns what to display for the first and second inputs (comments and scores).'''&lt;br /&gt;
  def complete_first_second_input(count, answer = nil)&lt;br /&gt;
    html = &amp;quot;&amp;lt;input id=\&amp;quot;responses_#{count.to_s}_comments\&amp;quot; name=\&amp;quot;responses[#{count.to_s}][comment]\&amp;quot; type=\&amp;quot;hidden\&amp;quot; value=\&amp;quot;\&amp;quot;&amp;gt;&amp;quot;&lt;br /&gt;
    html += &amp;quot;&amp;lt;input id=\&amp;quot;responses_#{count.to_s}_score\&amp;quot; name=\&amp;quot;responses[#{count.to_s}][score]\&amp;quot; type=\&amp;quot;hidden\&amp;quot;&amp;quot;&lt;br /&gt;
    html += if !answer.nil? &amp;amp;&amp;amp; (answer.answer == 1)&lt;br /&gt;
              'value=&amp;quot;1&amp;quot;'&lt;br /&gt;
            else&lt;br /&gt;
              'value=&amp;quot;0&amp;quot;'&lt;br /&gt;
            end&lt;br /&gt;
    html += '&amp;gt;'&lt;br /&gt;
    html&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  '''# Returns what to display for the third input (the checkbox itself).'''&lt;br /&gt;
  def complete_third_input(count, answer = nil)&lt;br /&gt;
    html = &amp;quot;&amp;lt;input id=\&amp;quot;responses_#{count.to_s}_checkbox\&amp;quot; type=\&amp;quot;checkbox\&amp;quot; onchange=\&amp;quot;checkbox#{count.to_s}Changed()\&amp;quot;&amp;quot;&lt;br /&gt;
    html += 'checked=&amp;quot;checked&amp;quot;' if !answer.nil? &amp;amp;&amp;amp; (answer.answer == 1)&lt;br /&gt;
    html += '&amp;gt;'&lt;br /&gt;
    html&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  '''# Create the executable script for client-side interaction on the checkbox'''&lt;br /&gt;
  def complete_script(count)&lt;br /&gt;
    html = &amp;quot;&amp;lt;script&amp;gt;function checkbox#{count.to_s}Changed() {&amp;quot;&lt;br /&gt;
    html += &amp;quot; var checkbox = jQuery(\&amp;quot;#responses_#{count.to_s}_checkbox\&amp;quot;);&amp;quot;&lt;br /&gt;
    html += &amp;quot; var response_score = jQuery(\&amp;quot;#responses_#{count.to_s}_score\&amp;quot;);&amp;quot;&lt;br /&gt;
    html += 'if (checkbox.is(&amp;quot;:checked&amp;quot;)) {'&lt;br /&gt;
    html += 'response_score.val(&amp;quot;1&amp;quot;);'&lt;br /&gt;
    html += '} else {'&lt;br /&gt;
    html += 'response_score.val(&amp;quot;0&amp;quot;);}}&amp;lt;/script&amp;gt;'&lt;br /&gt;
    html&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
'''2. DRY out code with partials'''&lt;br /&gt;
&lt;br /&gt;
Another one of our design goals is to implement additional partials for the question types. We added partials by looking at the similarities between all three question types and pull out the similarities into a new class.&lt;br /&gt;
*Ex: Question_Controller - Since all of the sub-categories inherit from the Question class we plan to make a question controller to hold all of the common functionality. One example of this can be seen with the method call 'edit' which exists in many of the subclasses like text_response.rb, text_area.rb, scale.rb, and criterion.rb. The partials will be moved into the question controller.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
&lt;br /&gt;
'''RSpec'''&lt;br /&gt;
&lt;br /&gt;
We reimplemented the test cases to match the changes we've made to the question-related models. Front-end testing wasn't necessary because our project doesn't involve changing any controller.&lt;br /&gt;
&lt;br /&gt;
The most notable models that were tested are:&lt;br /&gt;
 checkbox.rb &lt;br /&gt;
 criterion.rb&lt;br /&gt;
 dropdown.rb&lt;br /&gt;
 multiple_choice_checkbox.rb&lt;br /&gt;
 multiple_choice_radio.rb&lt;br /&gt;
 scale.rb&lt;br /&gt;
 text_area.rb&lt;br /&gt;
 text_field.rb&lt;br /&gt;
 text_response.rb&lt;br /&gt;
 upload_file.rb&lt;br /&gt;
&lt;br /&gt;
One of the primary goals we had were to make sure that the existing tests still passed. Several tests were removed for the edit methods in a few of the models (such as checkbox_spec.rb and dropdown_spec.rb) because those methods were replaced with partials. Partials have not been fully implemented which is why we did not include tests for them. However, this is something that should be revisited in the future.&lt;br /&gt;
&lt;br /&gt;
Given below is an example of the tests we've written:&lt;br /&gt;
 describe Dropdown do&lt;br /&gt;
  let!(:dropdown) { Dropdown.create(id: 4, type: 'Dropdown', seq: 4.0, txt: 'Test text', weight: 13) }&lt;br /&gt;
  let!(:answer) { Answer.create(id: 1, question_id: 4, questionnaire_type_id: 1, answer: 1, comments: &amp;quot;Test comment&amp;quot;) }&lt;br /&gt;
  describe '#view_question_text' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      html = dropdown.view_question_text&lt;br /&gt;
      expect(html).to eq('&amp;lt;TR&amp;gt;&amp;lt;TD align=&amp;quot;left&amp;quot;&amp;gt; Test text &amp;lt;/TD&amp;gt;&amp;lt;TD align=&amp;quot;left&amp;quot;&amp;gt;Dropdown&amp;lt;/TD&amp;gt;&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;13&amp;lt;/TD&amp;gt;&amp;lt;TD align=&amp;quot;center&amp;quot;&amp;gt;&amp;amp;mdash;&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#view_completed_question' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      html = dropdown.view_completed_question(1, answer)&lt;br /&gt;
      expect(html).to eq('&amp;lt;nowiki&amp;gt;&amp;lt;b&amp;gt;&amp;lt;/nowiki&amp;gt;1. Test text&amp;lt;nowiki&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;amp;nbsp&amp;amp;nbsp&amp;amp;nbsp&amp;amp;nbspTest comment')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#complete_for_alternatives' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      alternatives = ['Alternative 1', 'Alternative 2', 'Alternative 3']&lt;br /&gt;
      html = dropdown.complete_for_alternatives(alternatives, answer)&lt;br /&gt;
      expect(html).to eq('&amp;lt;option value=&amp;quot;Alternative 1&amp;quot;&amp;gt;Alternative 1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;Alternative 2&amp;quot;&amp;gt;Alternative 2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;Alternative 3&amp;quot;&amp;gt;Alternative 3&amp;lt;/option&amp;gt;')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#complete' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      alternatives = ['Alternative 1|Alternative 2|Alternative 3']&lt;br /&gt;
      allow(dropdown).to receive(:alternatives).and_return(alternatives)&lt;br /&gt;
      allow(dropdown).to receive(:complete_for_alternatives).and_return('')&lt;br /&gt;
      html = dropdown.complete(1, answer)&lt;br /&gt;
      &amp;lt;nowiki&amp;gt;expect(html).to eq('&amp;lt;p style=&amp;quot;width: 80%;&amp;quot;&amp;gt;&amp;lt;label for=&amp;quot;responses_1&amp;quot;&amp;quot;&amp;gt;Test text&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/label&amp;gt;'&lt;br /&gt;
      + '&amp;lt;input id=&amp;quot;responses_1_score&amp;quot; name=&amp;quot;responses[1][score]&amp;quot; type=&amp;quot;hidden&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;min-width: 100px;&amp;quot;&amp;gt;'&lt;br /&gt;
      + '&amp;lt;select id=&amp;quot;responses_1_comments&amp;quot; label=Test text name=&amp;quot;responses[1][comment]&amp;quot;&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/p&amp;gt;')&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Given below is the full list of tests:&lt;br /&gt;
&lt;br /&gt;
[[File:E2320-RSpec.png]]&lt;br /&gt;
&lt;br /&gt;
==Conclusions / Future Work==&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
[Will be updated near final submission deadline]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
* Prof. Edward F. Gehringer&lt;br /&gt;
* Priyam Garg&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Colleen Britt&lt;br /&gt;
* Kimberly Jones&lt;br /&gt;
* Priyanka Arghode&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://stackoverflow.com/questions/3425971/organizing-partials-for-a-polymorphic-resource Organizing Partials]&lt;br /&gt;
#[https://www.amberbit.com/blog/2011/12/27/render-views-and-partials-outside-controllers-in-rails-3 Render Views and Partials Outside Controllers]&lt;br /&gt;
#[https://github.com/pparghod/reimplementation-back-end Github Repo]&lt;br /&gt;
#[https://github.com/expertiza/reimplementation-back-end/pull/10 Link to initial pull request]&lt;br /&gt;
#[https://github.com/users/pparghod/projects/2/views/1 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Cbritt</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_Hierarchy&amp;diff=149207</id>
		<title>CSC/ECE 517 Spring 2023 - E2320. Reimplement the Question Hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_Hierarchy&amp;diff=149207"/>
		<updated>2023-04-08T00:34:27Z</updated>

		<summary type="html">&lt;p&gt;Cbritt: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Design Doc&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The current implementation of the question hierarchy is not very clean and contains confusing variable and method names. Also, many methods return long HTML strings which are difficult to read. The goal of this project is to reimplement this part of the application to make it more readable, understandable and maintainable.&lt;br /&gt;
&lt;br /&gt;
===Explanation of Feature - Question Hierarchy===&lt;br /&gt;
The Question class and its sub-classes are used to implement all rubric items, quiz questions, and survey questions in Expertiza. For example, a professor could use this feature to make up a review quiz for their class. There are 3 main types of questions in Experitza: scored, unscored, and upload file.&lt;br /&gt;
&lt;br /&gt;
Here is the hierarchy:&lt;br /&gt;
&lt;br /&gt;
'''1. Choice question'''&lt;br /&gt;
* Scored question&lt;br /&gt;
** Scale&lt;br /&gt;
** Criterion&lt;br /&gt;
* Unscored question&lt;br /&gt;
** Dropdown&lt;br /&gt;
** Multiple Choice&lt;br /&gt;
** Check Box&lt;br /&gt;
'''2. Text Response'''&lt;br /&gt;
* Text Area&lt;br /&gt;
* Text Field&lt;br /&gt;
'''3. Upload File'''&lt;br /&gt;
&lt;br /&gt;
Choice questions are types of questions that give the quiz taker a list of answers to choose from. It is broken into two subcategories scored and unscored. Scored question will give a number value depending upon if a user clicks on a particular answer. The unscored questions don't have  a score associated with them and come in a few different styles. The answers could be presented in a dropdown menu which only shows the answer choices after the user clicks on the dropdown arrow and clicks on an answer. Multiple choice questions present all the answers choices with a selectable bubble beside them and allow the user to click on the bubble to indicate their answer. Checkboxes are similar to multiple choice in that they present all of the answer choices at once however, the user must click on a certain number of boxes beside the answers they think are correct.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Text response questions are different in that they allow the user to actually type in their answer instead of just being provided answers. A text area question has a height and width associated with it that can be adjusted while a text field question is just 1 input line that does not change shape.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The last type of question is upload file which allows the user to upload a file to use as a quiz (as the name suggests). This option allows a person to upload a pre-made quiz document to be which will be converted into a quiz. So, a professor could type up their quiz questions and answers in a text file then choose upload and have Expertiza convert it into a quiz for them.&lt;br /&gt;
&lt;br /&gt;
===List of Work Done so Far===&lt;br /&gt;
The following list describes tasks that were accomplished in Program 3:&lt;br /&gt;
* Improved naming of variables and methods&lt;br /&gt;
* Included comments for further clarification&lt;br /&gt;
* Implemented partials to deal with the HTML strings&lt;br /&gt;
* Added RSpec test cases&lt;br /&gt;
&lt;br /&gt;
==Plan of work==&lt;br /&gt;
&lt;br /&gt;
Based on the feedback provided to us by both our mentors and also peer reviews our team has decided upon a few key design goals to work on for the continuation of our work into Program 4. These goals are outlined below.&lt;br /&gt;
&lt;br /&gt;
===Design Goals===&lt;br /&gt;
* Update code comments - Some methods and classes currently do not have any code comments, while other comments are not in depth enough to give proper context for functionality. One of our design goals will be to write more in depth comments that better explain functionality for the code. The below files are the ones which we plan too add more comments to:&lt;br /&gt;
**questionnaires_controller.rb&lt;br /&gt;
**checkbox.rb&lt;br /&gt;
**question.rb&lt;br /&gt;
**text_area.rb&lt;br /&gt;
**text_response.rb&lt;br /&gt;
* DRY out code with partials - Implement additional partials for certain classes. In program 3 our team had started to create partials for the 3 major types of questions. As we continue with program 4 we are going to continue to add more partials by looking at the similarities between all three types and pull out the similarities into a new class&lt;br /&gt;
**Ex: Question_Controller - Since all of the sub-categories inherit from the Question class we plan to make a question controller to hold all of the common functionality. One example of this can be seen with the method call 'edit' which exists in many of the subclasses like text_response.rb, text_area.rb, scale.rb, and criterion.rb. The partials will be moved into the question controller.&lt;br /&gt;
&lt;br /&gt;
== Tests ==&lt;br /&gt;
&lt;br /&gt;
'''RSpec'''&lt;br /&gt;
&lt;br /&gt;
We reimplemented the test cases to match the changes we've made to the question-related models. Front-end testing wasn't necessary because our project doesn't involve changing any controller.&lt;br /&gt;
&lt;br /&gt;
The most notable models that were tested are:&lt;br /&gt;
 checkbox.rb &lt;br /&gt;
 criterion.rb&lt;br /&gt;
 dropdown.rb&lt;br /&gt;
 multiple_choice_checkbox.rb&lt;br /&gt;
 multiple_choice_radio.rb&lt;br /&gt;
 scale.rb&lt;br /&gt;
 text_area.rb&lt;br /&gt;
 text_field.rb&lt;br /&gt;
 text_response.rb&lt;br /&gt;
 upload_file.rb&lt;br /&gt;
&lt;br /&gt;
One of the primary goals we had were to make sure that the existing tests still passed. Several tests were removed for the edit methods in a few of the models (such as checkbox_spec.rb and dropdown_spec.rb) because those methods were replaced with partials. Partials have not been fully implemented which is why we did not include tests for them. However, this is something that should be revisited in the future.&lt;br /&gt;
&lt;br /&gt;
Given below is an example of the tests we've written:&lt;br /&gt;
 describe Dropdown do&lt;br /&gt;
  let!(:dropdown) { Dropdown.create(id: 4, type: 'Dropdown', seq: 4.0, txt: 'Test text', weight: 13) }&lt;br /&gt;
  let!(:answer) { Answer.create(id: 1, question_id: 4, questionnaire_type_id: 1, answer: 1, comments: &amp;quot;Test comment&amp;quot;) }&lt;br /&gt;
  describe '#view_question_text' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      html = dropdown.view_question_text&lt;br /&gt;
      expect(html).to eq('&amp;lt;TR&amp;gt;&amp;lt;TD align=&amp;quot;left&amp;quot;&amp;gt; Test text &amp;lt;/TD&amp;gt;&amp;lt;TD align=&amp;quot;left&amp;quot;&amp;gt;Dropdown&amp;lt;/TD&amp;gt;&amp;lt;td align=&amp;quot;center&amp;quot;&amp;gt;13&amp;lt;/TD&amp;gt;&amp;lt;TD align=&amp;quot;center&amp;quot;&amp;gt;&amp;amp;mdash;&amp;lt;/TD&amp;gt;&amp;lt;/TR&amp;gt;')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#view_completed_question' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      html = dropdown.view_completed_question(1, answer)&lt;br /&gt;
      expect(html).to eq('&amp;lt;nowiki&amp;gt;&amp;lt;b&amp;gt;&amp;lt;/nowiki&amp;gt;1. Test text&amp;lt;nowiki&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;BR&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;amp;nbsp&amp;amp;nbsp&amp;amp;nbsp&amp;amp;nbspTest comment')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#complete_for_alternatives' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      alternatives = ['Alternative 1', 'Alternative 2', 'Alternative 3']&lt;br /&gt;
      html = dropdown.complete_for_alternatives(alternatives, answer)&lt;br /&gt;
      expect(html).to eq('&amp;lt;option value=&amp;quot;Alternative 1&amp;quot;&amp;gt;Alternative 1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;Alternative 2&amp;quot;&amp;gt;Alternative 2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;Alternative 3&amp;quot;&amp;gt;Alternative 3&amp;lt;/option&amp;gt;')&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
  describe '#complete' do&lt;br /&gt;
    it 'returns the html' do&lt;br /&gt;
      alternatives = ['Alternative 1|Alternative 2|Alternative 3']&lt;br /&gt;
      allow(dropdown).to receive(:alternatives).and_return(alternatives)&lt;br /&gt;
      allow(dropdown).to receive(:complete_for_alternatives).and_return('')&lt;br /&gt;
      html = dropdown.complete(1, answer)&lt;br /&gt;
      &amp;lt;nowiki&amp;gt;expect(html).to eq('&amp;lt;p style=&amp;quot;width: 80%;&amp;quot;&amp;gt;&amp;lt;label for=&amp;quot;responses_1&amp;quot;&amp;quot;&amp;gt;Test text&amp;amp;nbsp;&amp;amp;nbsp;&amp;lt;/label&amp;gt;'&lt;br /&gt;
      + '&amp;lt;input id=&amp;quot;responses_1_score&amp;quot; name=&amp;quot;responses[1][score]&amp;quot; type=&amp;quot;hidden&amp;quot; value=&amp;quot;&amp;quot; style=&amp;quot;min-width: 100px;&amp;quot;&amp;gt;'&lt;br /&gt;
      + '&amp;lt;select id=&amp;quot;responses_1_comments&amp;quot; label=Test text name=&amp;quot;responses[1][comment]&amp;quot;&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/p&amp;gt;')&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Given below is the full list of tests:&lt;br /&gt;
&lt;br /&gt;
[[File:E2320-RSpec.png]]&lt;br /&gt;
&lt;br /&gt;
==Conclusions / Future Work==&lt;br /&gt;
===Specific Tasks Completed===&lt;br /&gt;
[Will be updated near final submission deadline]&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
* Prof. Edward F. Gehringer&lt;br /&gt;
* Priyam Garg&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Colleen Britt&lt;br /&gt;
* Kimberly Jones&lt;br /&gt;
* Priyanka Arghode&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://stackoverflow.com/questions/3425971/organizing-partials-for-a-polymorphic-resource Organizing Partials]&lt;br /&gt;
#[https://www.amberbit.com/blog/2011/12/27/render-views-and-partials-outside-controllers-in-rails-3 Render Views and Partials Outside Controllers]&lt;br /&gt;
#[https://github.com/pparghod/reimplementation-back-end Github Repo]&lt;br /&gt;
#[https://github.com/expertiza/reimplementation-back-end/pull/10 Link to initial pull request]&lt;br /&gt;
#[https://github.com/users/pparghod/projects/2/views/1 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Cbritt</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:E2320-RSpec.png&amp;diff=149193</id>
		<title>File:E2320-RSpec.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:E2320-RSpec.png&amp;diff=149193"/>
		<updated>2023-04-08T00:17:39Z</updated>

		<summary type="html">&lt;p&gt;Cbritt: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Cbritt</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_hierarchy&amp;diff=148519</id>
		<title>CSC/ECE 517 Spring 2023 - E2320. Reimplement the Question hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_hierarchy&amp;diff=148519"/>
		<updated>2023-03-28T00:48:19Z</updated>

		<summary type="html">&lt;p&gt;Cbritt: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. Instructors have the ability to add new projects, assignments, etc., as well as edit existing ones. Later on, they can view student submissions and grade them. Students can also use Expertiza to organize into teams to work on different projects and assignments and submit their work. They can also review other students' submissions.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The current implementation of the question hierarchy is not very clean and contains confusing variable and method names. Also, many methods return long HTML strings which are difficult to read. The goal of this project is to reimplement this part of the application to make it more readable, understandable and maintainable.&lt;br /&gt;
&lt;br /&gt;
Tasks that were accomplished:&lt;br /&gt;
* Improved naming of variables and methods&lt;br /&gt;
* Included comments for further clarification&lt;br /&gt;
* Implemented partials to deal with the HTML strings&lt;br /&gt;
* Added RSpec test cases&lt;br /&gt;
&lt;br /&gt;
==Question Hierarchy==&lt;br /&gt;
&lt;br /&gt;
The Question class and its sub-classes are used to implement all rubric items, quiz questions, and survey questions in Expertiza.&lt;br /&gt;
&lt;br /&gt;
Here is the hierarchy:&lt;br /&gt;
&lt;br /&gt;
'''1. Choice question'''&lt;br /&gt;
* Scored question&lt;br /&gt;
** Scale&lt;br /&gt;
** Criterion&lt;br /&gt;
* Unscored question&lt;br /&gt;
** Dropdown&lt;br /&gt;
** Multiple Choice&lt;br /&gt;
** Check Box&lt;br /&gt;
'''2. Text Response'''&lt;br /&gt;
* Text Area&lt;br /&gt;
* Text Field&lt;br /&gt;
'''3. Upload File'''&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
There were multiple files that we needed to transfer from the old repository to make the models work, and we've had to comment out a lot of code. There were many file dependencies regarding questionnaires and questions. We've minimized it as much as we could to stay within the scope of our project.&lt;br /&gt;
&lt;br /&gt;
Below are the files we changed or added in as part of the reimplementation.&lt;br /&gt;
&lt;br /&gt;
 questionnaires_controller.rb&lt;br /&gt;
 answer.rb&lt;br /&gt;
 application_record.rb&lt;br /&gt;
 assignment.rb&lt;br /&gt;
 assignment_questionnaire.rb&lt;br /&gt;
 checkbox.rb&lt;br /&gt;
 choice_question.rb&lt;br /&gt;
 criterion.rb&lt;br /&gt;
 dropdown.rb&lt;br /&gt;
 multiple_choice_checkbox.rb&lt;br /&gt;
 multiple_choice_radio.rb&lt;br /&gt;
 question.rb&lt;br /&gt;
 question_advice.rb&lt;br /&gt;
 questionnaire.rb&lt;br /&gt;
 quiz_question.rb&lt;br /&gt;
 quiz_question_choice.rb&lt;br /&gt;
 role.rb&lt;br /&gt;
 scale.rb&lt;br /&gt;
 scored_question.rb&lt;br /&gt;
 text_area.rb&lt;br /&gt;
 text_field.rb&lt;br /&gt;
 text_response.rb&lt;br /&gt;
 unscored_question.rb&lt;br /&gt;
 upload_file.rb&lt;br /&gt;
 user.rb&lt;br /&gt;
&lt;br /&gt;
==Reimplementation==&lt;br /&gt;
As a part of the reimplementation project, migrations were created, added relevant old code files and partials are included in the old code files to avoid HTML concatenation. There exist many cases in the Question hierarchy were HTML string concatenation is being used to generate a view. In order to reduce duplicated code and DRY it out we added partials to replace the existing HTML string. This will help to keep the code cleaner and easier to maintain for future use. &lt;br /&gt;
&lt;br /&gt;
'''Our code'''&lt;br /&gt;
&lt;br /&gt;
Below is an example of a partial being used in the `criterion.rb` class file:&lt;br /&gt;
&lt;br /&gt;
[[File:Partials1.PNG]]&lt;br /&gt;
&lt;br /&gt;
Below is an example of a partial being used the `scale.rb` class file:&lt;br /&gt;
&lt;br /&gt;
[[File:Partials2.PNG]]&lt;br /&gt;
&lt;br /&gt;
Below shows the differences in code before and after adding the partial. While refactoring our code we found that this edit method was being duplicated between the Criterion class and the Scale class. Now after using a partial, the large chunk of duplicated code is simplified into a one line partial. This will help future developers who wish to make an change to the edit method without having to change multiple files.&lt;br /&gt;
&lt;br /&gt;
[[File:7.PNG]]&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Other refactoring changes we worked on included updating variable names for some of the models and migrations. Below are some snapshots of our code where these changes were made:&lt;br /&gt;
[[File:1.PNG]] &lt;br /&gt;
&lt;br /&gt;
[[File:3.PNG]] &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Another refactoring change we worked on was adding correct comments to the code for better readability and explanation of the code. Below are a few examples:&lt;br /&gt;
&lt;br /&gt;
[[File:5.PNG]]&lt;br /&gt;
&lt;br /&gt;
[[File:6.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Testing  Plan ==&lt;br /&gt;
&lt;br /&gt;
'''RSpec'''&lt;br /&gt;
&lt;br /&gt;
We reimplemented the test cases to match the changes we've made to the question-related models. Front-end testing wasn't necessary because our project doesn't involve changing any controller.&lt;br /&gt;
&lt;br /&gt;
The most notable models that were tested are:&lt;br /&gt;
 checkbox.rb &lt;br /&gt;
 criterion.rb&lt;br /&gt;
 dropdown.rb&lt;br /&gt;
 multiple_choice_checkbox.rb&lt;br /&gt;
 multiple_choice_radio.rb&lt;br /&gt;
 scale.rb&lt;br /&gt;
 text_area.rb&lt;br /&gt;
 text_field.rb&lt;br /&gt;
 text_response.rb&lt;br /&gt;
 upload_file.rb&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
'''Continue to DRY out code using partials'''&lt;br /&gt;
* There are still many more files and sections of code that could benefit from the use of partials that we were unable to finish for round 1 (Ex: UploadFile). As we move into round 2, we will continue to look for more refactoring opportunities in order to better utilize partials.&lt;br /&gt;
'''More testing'''&lt;br /&gt;
* Since testing is a crucial element of this project we will continue to work on developing tests for our code changes.&lt;br /&gt;
'''Implement Front-end'''&lt;br /&gt;
* We've implemented the back-end part of the project but not the front-end. We've added several &amp;quot;views&amp;quot; files to make use of partials, so the front-end could be implemented by updating them and implementing the rest of the Rails application. It's also possible to create an entirely new front-end by using JavaScript and React.&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
* Prof. Edward F. Gehringer&lt;br /&gt;
* Priyam Garg&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Colleen Britt&lt;br /&gt;
* Kimberly Jones&lt;br /&gt;
* Priyanka Arghode&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://stackoverflow.com/questions/3425971/organizing-partials-for-a-polymorphic-resource Organizing Partials]&lt;br /&gt;
#[https://www.amberbit.com/blog/2011/12/27/render-views-and-partials-outside-controllers-in-rails-3 Render Views and Partials Outside Controllers]&lt;br /&gt;
#[https://github.com/pparghod/reimplementation-back-end Github Repo]&lt;br /&gt;
#[https://github.com/expertiza/reimplementation-back-end/pull/10 Link to initial pull request]&lt;br /&gt;
#[https://github.com/users/pparghod/projects/2/views/1 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Cbritt</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_hierarchy&amp;diff=148032</id>
		<title>CSC/ECE 517 Spring 2023 - E2320. Reimplement the Question hierarchy</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2023_-_E2320._Reimplement_the_Question_hierarchy&amp;diff=148032"/>
		<updated>2023-03-22T23:27:56Z</updated>

		<summary type="html">&lt;p&gt;Cbritt: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Expertiza==&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ Expertiza] is a [http://rubyonrails.org/ Ruby on Rails] based open source project. Instructors have the ability to add new projects, assignments, etc., as well as edit existing ones. Later on, they can view student submissions and grade them. Students can also use Expertiza to organize into teams to work on different projects and assignments and submit their work. They can also review other students' submissions.&lt;br /&gt;
&lt;br /&gt;
==Problem Statement==&lt;br /&gt;
The current implementation of the question hierarchy is not very clean and contains confusing variable and method names. Also, many methods return long HTML strings which are difficult to read. The goal of this project is to reimplement this part of the application to make it more readable, understandable and maintainable.&lt;br /&gt;
&lt;br /&gt;
Tasks that were accomplished:&lt;br /&gt;
* Improved naming of variables and methods&lt;br /&gt;
* Included comments for further clarification&lt;br /&gt;
* Implemented partials to deal with the HTML strings&lt;br /&gt;
* Added RSpec test cases&lt;br /&gt;
&lt;br /&gt;
==Question Hierarchy==&lt;br /&gt;
&lt;br /&gt;
The Question class and its sub-classes are used to implement all rubric items, quiz questions, and survey questions in Expertiza.&lt;br /&gt;
&lt;br /&gt;
Here is the hierarchy:&lt;br /&gt;
=====1. Choice question=====&lt;br /&gt;
* Scored question&lt;br /&gt;
** Scale&lt;br /&gt;
** Criterion&lt;br /&gt;
* Unscored question&lt;br /&gt;
** Dropdown&lt;br /&gt;
** Multiple Choice&lt;br /&gt;
** Check Box&lt;br /&gt;
=====2. Text Response=====&lt;br /&gt;
* Text Area&lt;br /&gt;
* Text Field&lt;br /&gt;
=====3. Upload File=====&lt;br /&gt;
&lt;br /&gt;
==Files Modified==&lt;br /&gt;
&lt;br /&gt;
Below are the files we changed as part of the reimplementation.&lt;br /&gt;
&lt;br /&gt;
 question.rb&lt;br /&gt;
 scale.rb&lt;br /&gt;
 criterion.rb&lt;br /&gt;
 text_area.rb&lt;br /&gt;
 text_field.rb&lt;br /&gt;
 text_response.rb&lt;br /&gt;
 questionnaires_controller.rb&lt;br /&gt;
 answer.rb&lt;br /&gt;
 checkbox.rb&lt;br /&gt;
 choice_question.rb&lt;br /&gt;
 dropdown.rb&lt;br /&gt;
 multiple_choice_checkbox.rb&lt;br /&gt;
 multiple_choice_radio.rb&lt;br /&gt;
 question.rb&lt;br /&gt;
 question_advice.rb&lt;br /&gt;
 questionnaire.rb&lt;br /&gt;
 quiz_question.rb&lt;br /&gt;
 quiz_question_choice.rb&lt;br /&gt;
 scored_question.rb&lt;br /&gt;
 unscored_question.rb&lt;br /&gt;
 assignment_questionnaire.rb&lt;br /&gt;
&lt;br /&gt;
==Reimplementation==&lt;br /&gt;
As a part of the reimplementation project, migrations were created, added relevant old code files and partials are included in the old code files to avoid HTML concatenation. There exist many cases in the Question hierarchy were HTML string concatenation is being used to generate a view. In order to reduce duplicated code and DRY it out we added partials to replace the existing HTML string. This will help to keep the code cleaner and easier to maintain for future use. &lt;br /&gt;
&lt;br /&gt;
'''Our code'''&lt;br /&gt;
&lt;br /&gt;
Below is an example of a partial being used in the `criterion.rb` class file:&lt;br /&gt;
[[File:Partials1.PNG]]&lt;br /&gt;
&lt;br /&gt;
Below is an example of a partial being used the `scale.rb` class file:&lt;br /&gt;
[[File:Partials2.PNG]]&lt;br /&gt;
&lt;br /&gt;
Below shows the differences in code before and after adding the partial. While refactoring our code we found that this edit method was being duplicated between the Criterion class and the Scale class. Now after using a partial, the large chunk of duplicated code is simplified into a one line partial. This will help future developers who wish to make an change to the edit method without having to change multiple files.&lt;br /&gt;
&lt;br /&gt;
[[File:7.PNG]]&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Other refactoring changes we worked on included updating variable names for some of the models and migrations. Below are some snapshots of our code where these changes were made:&lt;br /&gt;
[[File:1.PNG]] &lt;br /&gt;
&lt;br /&gt;
[[File:3.PNG]] &lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Another refactoring change we worked on was adding correct comments to the code for better readability and explanation of the code. Below are a few examples:&lt;br /&gt;
&lt;br /&gt;
[[File:5.PNG]]&lt;br /&gt;
&lt;br /&gt;
[[File:6.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Testing  Plan ==&lt;br /&gt;
=====RSpec=====&lt;br /&gt;
We reimplemented the test cases to match the changes we've made to the question-related models. Front-end testing wasn't necessary because our project doesn't involve changing any controller.&lt;br /&gt;
&lt;br /&gt;
The most notable models are:&lt;br /&gt;
* checkbox.rb&lt;br /&gt;
* criterion.rb&lt;br /&gt;
* dropdown.rb&lt;br /&gt;
* multiple_choice_checkbox.rb&lt;br /&gt;
* multiple_choice_radio.rb&lt;br /&gt;
* scale.rb&lt;br /&gt;
* text_area.rb&lt;br /&gt;
* text_field.rb&lt;br /&gt;
* text_response.rb&lt;br /&gt;
&lt;br /&gt;
== Next Steps ==&lt;br /&gt;
* Continue to DRY out code using partials - There are still many more files and sections of code that could benefit from the use of partials that we were unable to finish for round 1 (Ex: UploadFile). As we move into round 2 we will continue to look for more refactoring opportunities in order to better utilize partials.&lt;br /&gt;
* Finish testing - Since testing is a crucial element of this project we will continue to work on developing tests for our code changes. We were unable to finish testing for a few classes (Scored Question, TextResponse)&lt;br /&gt;
&lt;br /&gt;
==Team==&lt;br /&gt;
=====Mentor===== &lt;br /&gt;
* Prof. Edward F. Gehringer&lt;br /&gt;
* Priyam Garg&lt;br /&gt;
&lt;br /&gt;
=====Members===== &lt;br /&gt;
* Colleen Britt&lt;br /&gt;
* Kimberly Jones&lt;br /&gt;
* Priyanka Arghode&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
#[https://expertiza.ncsu.edu/ Expertiza]&lt;br /&gt;
#[https://stackoverflow.com/questions/3425971/organizing-partials-for-a-polymorphic-resource Organizing Partials]&lt;br /&gt;
#[https://www.amberbit.com/blog/2011/12/27/render-views-and-partials-outside-controllers-in-rails-3 Render Views and Partials Outside Controllers]&lt;br /&gt;
#[https://github.com/pparghod/reimplementation-back-end Github Repo]&lt;br /&gt;
#[https://github.com/expertiza/reimplementation-back-end/pull/10 Link to initial pull request]&lt;br /&gt;
#[https://github.com/users/pparghod/projects/2/views/1 GitHub Project Board]&lt;/div&gt;</summary>
		<author><name>Cbritt</name></author>
	</entry>
</feed>