<?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=Pgandhi4</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=Pgandhi4"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Pgandhi4"/>
	<updated>2026-07-14T12:05:26Z</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_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=164419</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=164419"/>
		<updated>2025-04-22T00:09:20Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2529. Testing for the Questionnaire Helper in Expertiza&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project focuses on developing test cases for the questionnaire_helper module within Expertiza, an open-source assignment and project management system built using Ruby on Rails. The platform supports collaborative learning by enabling instructors to design assignments, set up topics for sign-up, and organize student teams. Meanwhile, students can choose topics, work in groups, and engage in peer assessments to support each other's learning. The primary aim of this project is to create thorough test plans and improve code coverage for these helper modules, ensuring their functionality and dependability within the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi (pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Dependency Injection Principle (DIP)&lt;br /&gt;
The QuestionnaireHelper methods accept objects like questionnaire or scored_question as parameters rather than instantiating them internally. This reflects the Dependency Injection Principle, promoting loose coupling. It also makes the methods easier to test and reuse, since dependencies are provided externally and can be mocked or substituted as needed.&lt;br /&gt;
&lt;br /&gt;
* Single Responsibility Principle (SRP)&lt;br /&gt;
Each method in the QuestionnaireHelper module demonstrates the Single Responsibility Principle by handling a specific, well-defined task. For instance, the adjust_advice_size method is solely focused on resizing the advice fields based on score ranges, while the questionnaire_factory method exclusively deals with instantiating questionnaire objects depending on their type. This separation of concerns enhances both the clarity and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP)&lt;br /&gt;
Although not immediately visible in limited code snippets, the design follows the Open/Closed Principle by being open to extension but closed to modification. For example, to support new questionnaire types, developers can extend the logic in questionnaire_factory without altering the existing structure, making the system more scalable and adaptable to future changes.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern&lt;br /&gt;
The questionnaire_factory method resembles the Factory Method Pattern by generating different types of questionnaire instances based on input parameters. This pattern enables the dynamic creation of objects without hard-coding their specific classes, improving flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
* Strategy Pattern&lt;br /&gt;
Another applicable pattern is the Strategy Pattern, especially relevant if the behavior of questionnaires (e.g., scoring, rendering, or validation) varies by type. If such behaviors are encapsulated in interchangeable classes and selected at runtime (possibly via the factory method), it aligns well with the Strategy Pattern. This promotes code reusability and simplifies the addition of new behavior types without impacting existing logic.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The adjust_advice_size method ensures that every ScoredQuestion has exactly one QuestionAdvice for each score in the range defined by its parent questionnaire. It removes advice entries outside the valid range and eliminates duplicates, while also creating missing entries for scores within range.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Create a mock or real Questionnaire instance with:&lt;br /&gt;
  min_question_score = 1&lt;br /&gt;
  max_question_score = 5&lt;br /&gt;
&lt;br /&gt;
* Create a ScoredQuestion with:&lt;br /&gt;
  id assigned&lt;br /&gt;
  question_advices association&lt;br /&gt;
&lt;br /&gt;
* Populate the QuestionAdvice table with:&lt;br /&gt;
  Advice entries within the valid range&lt;br /&gt;
  Advice entries outside the valid range&lt;br /&gt;
  Duplicate advice entries for the same score&lt;br /&gt;
&lt;br /&gt;
* Stub or use an in-memory DB to test without affecting real data.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: question is not a ScoredQuestion&lt;br /&gt;
  Should perform no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: question is a ScoredQuestion, with:&lt;br /&gt;
  Valid advice range entries → should remain untouched.&lt;br /&gt;
  Advice with scores outside [min, max] → should be deleted.&lt;br /&gt;
  Duplicate advice entries → should be reduced to one.&lt;br /&gt;
  Missing advice entries within valid range → should be created.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, the method should exit early and make no database changes.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Only one QuestionAdvice should exist for each score in [min, max].&lt;br /&gt;
  No QuestionAdvice should exist with scores outside [min, max].&lt;br /&gt;
  All newly created QuestionAdvice entries should have the correct score and question_id.&lt;br /&gt;
  The total number of QuestionAdvice entries for the question should equal (max - min + 1).&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The questionnaire_factory method is responsible for dynamically creating a new instance of a questionnaire based on a type string provided as input. It uses the QUESTIONNAIRE_MAP constant to resolve the correct class. If the type is not recognized, it sets an error message in the flash hash and returns nil.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Ensure QUESTIONNAIRE_MAP is correctly defined with mappings like:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;ReviewQuestionnaire&amp;quot; =&amp;gt; ReviewQuestionnaire,&lt;br /&gt;
  &amp;quot;SurveyQuestionnaire&amp;quot; =&amp;gt; SurveyQuestionnaire&lt;br /&gt;
  }&lt;br /&gt;
* Stub or create minimal versions of the questionnaire classes (ReviewQuestionnaire, etc.) that support .new.&lt;br /&gt;
* Mock the flash hash to observe changes when the type is invalid.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: Valid questionnaire type is provided (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;).&lt;br /&gt;
  Should return a new instance of ReviewQuestionnaire.&lt;br /&gt;
&lt;br /&gt;
* Context 2: Invalid questionnaire type is provided (e.g., &amp;quot;InvalidType&amp;quot;).&lt;br /&gt;
  Should set an error message in flash[:error].&lt;br /&gt;
  Should return nil.&lt;br /&gt;
&lt;br /&gt;
* Context 3: type is nil or an empty string.&lt;br /&gt;
  Should be treated as an invalid type.&lt;br /&gt;
  Should set flash error and return nil.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1:&lt;br /&gt;
  A new instance of the correct class is returned.&lt;br /&gt;
  No flash error is set.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  flash[:error] is set to 'Error: Undefined Questionnaire'.&lt;br /&gt;
  The method returns nil.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Same expectations as Context 2 (error set, return nil).&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The update_questionnaire_questions method updates existing Question records with new attribute values received from the request parameters. It ensures that only the changed attributes are updated and saved, thereby optimizing database writes.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ====&lt;br /&gt;
* Define params[:question] as a hash with:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;1&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Updated question text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;2&amp;quot; },&lt;br /&gt;
  &amp;quot;2&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Another text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;1&amp;quot; }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* Create corresponding Question objects with:&lt;br /&gt;
  IDs 1 and 2&lt;br /&gt;
  Initial attributes set to different values or the same (for testing updates vs no-ops)&lt;br /&gt;
&lt;br /&gt;
* Stub or set up the params object inside a test controller or context.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
* Context 1: params[:question] is nil&lt;br /&gt;
   Method should return immediately and make no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: params[:question] contains valid data&lt;br /&gt;
  Some attributes differ from the existing Question values → should update and save.&lt;br /&gt;
  Some attributes match existing values → should not update those fields.&lt;br /&gt;
&lt;br /&gt;
* Context 3: Mixed changes&lt;br /&gt;
  One Question has all new values → should be updated and saved.&lt;br /&gt;
  One Question has no changed values → should not call save.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, no Question records should be loaded or updated.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Each Question should receive updated values only for attributes that differ.&lt;br /&gt;
  question.save should be called only if at least one attribute is updated.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Only Question objects with modified attributes should trigger a .save call.&lt;br /&gt;
  Attributes already matching current values should not be re-assigned.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: 42.86%&lt;br /&gt;
* Current coverage: 100.00%&lt;br /&gt;
[[File:number_of_cases.png|500px]]&lt;br /&gt;
[[File:lines_covered.jpg|500px]]&lt;br /&gt;
[[File:new_code.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document presents a comprehensive strategy to improve testing and code coverage for the questionnaire_helper files in Expertiza. With clear objectives such as creating detailed test plans and scenarios, the project seeks to close existing coverage gaps. While the questionnaire_helper.rb file showed only slight improvements—mainly because the update_questionnaire_questions method was already fully covered—the focus now shifts to executing the proposed test plans to ensure robust testing and reliability across all key functionalities in both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
* GitHub Pull Request: [https://github.com/expertiza/expertiza/pull/2950 Pull Request]&lt;br /&gt;
* GitHub Repository: [https://github.com/ishani-rajput/expertiza Github]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=164416</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=164416"/>
		<updated>2025-04-22T00:08:24Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2529. Testing for the Questionnaire Helper in Expertiza&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project focuses on developing test cases for the questionnaire_helper module within Expertiza, an open-source assignment and project management system built using Ruby on Rails. The platform supports collaborative learning by enabling instructors to design assignments, set up topics for sign-up, and organize student teams. Meanwhile, students can choose topics, work in groups, and engage in peer assessments to support each other's learning. The primary aim of this project is to create thorough test plans and improve code coverage for these helper modules, ensuring their functionality and dependability within the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi (pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Dependency Injection Principle (DIP)&lt;br /&gt;
The QuestionnaireHelper methods accept objects like questionnaire or scored_question as parameters rather than instantiating them internally. This reflects the Dependency Injection Principle, promoting loose coupling. It also makes the methods easier to test and reuse, since dependencies are provided externally and can be mocked or substituted as needed.&lt;br /&gt;
&lt;br /&gt;
* Single Responsibility Principle (SRP)&lt;br /&gt;
Each method in the QuestionnaireHelper module demonstrates the Single Responsibility Principle by handling a specific, well-defined task. For instance, the adjust_advice_size method is solely focused on resizing the advice fields based on score ranges, while the questionnaire_factory method exclusively deals with instantiating questionnaire objects depending on their type. This separation of concerns enhances both the clarity and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP)&lt;br /&gt;
Although not immediately visible in limited code snippets, the design follows the Open/Closed Principle by being open to extension but closed to modification. For example, to support new questionnaire types, developers can extend the logic in questionnaire_factory without altering the existing structure, making the system more scalable and adaptable to future changes.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern&lt;br /&gt;
The questionnaire_factory method resembles the Factory Method Pattern by generating different types of questionnaire instances based on input parameters. This pattern enables the dynamic creation of objects without hard-coding their specific classes, improving flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
* Strategy Pattern&lt;br /&gt;
Another applicable pattern is the Strategy Pattern, especially relevant if the behavior of questionnaires (e.g., scoring, rendering, or validation) varies by type. If such behaviors are encapsulated in interchangeable classes and selected at runtime (possibly via the factory method), it aligns well with the Strategy Pattern. This promotes code reusability and simplifies the addition of new behavior types without impacting existing logic.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The adjust_advice_size method ensures that every ScoredQuestion has exactly one QuestionAdvice for each score in the range defined by its parent questionnaire. It removes advice entries outside the valid range and eliminates duplicates, while also creating missing entries for scores within range.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Create a mock or real Questionnaire instance with:&lt;br /&gt;
  min_question_score = 1&lt;br /&gt;
  max_question_score = 5&lt;br /&gt;
&lt;br /&gt;
* Create a ScoredQuestion with:&lt;br /&gt;
  id assigned&lt;br /&gt;
  question_advices association&lt;br /&gt;
&lt;br /&gt;
* Populate the QuestionAdvice table with:&lt;br /&gt;
  Advice entries within the valid range&lt;br /&gt;
  Advice entries outside the valid range&lt;br /&gt;
  Duplicate advice entries for the same score&lt;br /&gt;
&lt;br /&gt;
* Stub or use an in-memory DB to test without affecting real data.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: question is not a ScoredQuestion&lt;br /&gt;
  Should perform no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: question is a ScoredQuestion, with:&lt;br /&gt;
  Valid advice range entries → should remain untouched.&lt;br /&gt;
  Advice with scores outside [min, max] → should be deleted.&lt;br /&gt;
  Duplicate advice entries → should be reduced to one.&lt;br /&gt;
  Missing advice entries within valid range → should be created.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, the method should exit early and make no database changes.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Only one QuestionAdvice should exist for each score in [min, max].&lt;br /&gt;
  No QuestionAdvice should exist with scores outside [min, max].&lt;br /&gt;
  All newly created QuestionAdvice entries should have the correct score and question_id.&lt;br /&gt;
  The total number of QuestionAdvice entries for the question should equal (max - min + 1).&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The questionnaire_factory method is responsible for dynamically creating a new instance of a questionnaire based on a type string provided as input. It uses the QUESTIONNAIRE_MAP constant to resolve the correct class. If the type is not recognized, it sets an error message in the flash hash and returns nil.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Ensure QUESTIONNAIRE_MAP is correctly defined with mappings like:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;ReviewQuestionnaire&amp;quot; =&amp;gt; ReviewQuestionnaire,&lt;br /&gt;
  &amp;quot;SurveyQuestionnaire&amp;quot; =&amp;gt; SurveyQuestionnaire&lt;br /&gt;
  }&lt;br /&gt;
* Stub or create minimal versions of the questionnaire classes (ReviewQuestionnaire, etc.) that support .new.&lt;br /&gt;
* Mock the flash hash to observe changes when the type is invalid.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: Valid questionnaire type is provided (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;).&lt;br /&gt;
  Should return a new instance of ReviewQuestionnaire.&lt;br /&gt;
&lt;br /&gt;
* Context 2: Invalid questionnaire type is provided (e.g., &amp;quot;InvalidType&amp;quot;).&lt;br /&gt;
  Should set an error message in flash[:error].&lt;br /&gt;
  Should return nil.&lt;br /&gt;
&lt;br /&gt;
* Context 3: type is nil or an empty string.&lt;br /&gt;
  Should be treated as an invalid type.&lt;br /&gt;
  Should set flash error and return nil.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1:&lt;br /&gt;
  A new instance of the correct class is returned.&lt;br /&gt;
  No flash error is set.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  flash[:error] is set to 'Error: Undefined Questionnaire'.&lt;br /&gt;
  The method returns nil.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Same expectations as Context 2 (error set, return nil).&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The update_questionnaire_questions method updates existing Question records with new attribute values received from the request parameters. It ensures that only the changed attributes are updated and saved, thereby optimizing database writes.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ====&lt;br /&gt;
* Define params[:question] as a hash with:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;1&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Updated question text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;2&amp;quot; },&lt;br /&gt;
  &amp;quot;2&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Another text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;1&amp;quot; }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* Create corresponding Question objects with:&lt;br /&gt;
  IDs 1 and 2&lt;br /&gt;
  Initial attributes set to different values or the same (for testing updates vs no-ops)&lt;br /&gt;
&lt;br /&gt;
* Stub or set up the params object inside a test controller or context.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
* Context 1: params[:question] is nil&lt;br /&gt;
   Method should return immediately and make no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: params[:question] contains valid data&lt;br /&gt;
  Some attributes differ from the existing Question values → should update and save.&lt;br /&gt;
  Some attributes match existing values → should not update those fields.&lt;br /&gt;
&lt;br /&gt;
* Context 3: Mixed changes&lt;br /&gt;
  One Question has all new values → should be updated and saved.&lt;br /&gt;
  One Question has no changed values → should not call save.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, no Question records should be loaded or updated.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Each Question should receive updated values only for attributes that differ.&lt;br /&gt;
  question.save should be called only if at least one attribute is updated.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Only Question objects with modified attributes should trigger a .save call.&lt;br /&gt;
  Attributes already matching current values should not be re-assigned.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: 42.86%&lt;br /&gt;
* Current coverage: 100.00%&lt;br /&gt;
[[File:Number_of_cases.jpg|500px]]&lt;br /&gt;
[[File:lines_covered.jpg|500px]]&lt;br /&gt;
[[File:new_code.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document presents a comprehensive strategy to improve testing and code coverage for the questionnaire_helper files in Expertiza. With clear objectives such as creating detailed test plans and scenarios, the project seeks to close existing coverage gaps. While the questionnaire_helper.rb file showed only slight improvements—mainly because the update_questionnaire_questions method was already fully covered—the focus now shifts to executing the proposed test plans to ensure robust testing and reliability across all key functionalities in both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
* GitHub Pull Request: [https://github.com/expertiza/expertiza/pull/2950 Pull Request]&lt;br /&gt;
* GitHub Repository: [https://github.com/ishani-rajput/expertiza Github]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=164415</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=164415"/>
		<updated>2025-04-22T00:05:32Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2529. Testing for the Questionnaire Helper in Expertiza&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project focuses on developing test cases for the questionnaire_helper module within Expertiza, an open-source assignment and project management system built using Ruby on Rails. The platform supports collaborative learning by enabling instructors to design assignments, set up topics for sign-up, and organize student teams. Meanwhile, students can choose topics, work in groups, and engage in peer assessments to support each other's learning. The primary aim of this project is to create thorough test plans and improve code coverage for these helper modules, ensuring their functionality and dependability within the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi (pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Dependency Injection Principle (DIP)&lt;br /&gt;
The QuestionnaireHelper methods accept objects like questionnaire or scored_question as parameters rather than instantiating them internally. This reflects the Dependency Injection Principle, promoting loose coupling. It also makes the methods easier to test and reuse, since dependencies are provided externally and can be mocked or substituted as needed.&lt;br /&gt;
&lt;br /&gt;
* Single Responsibility Principle (SRP)&lt;br /&gt;
Each method in the QuestionnaireHelper module demonstrates the Single Responsibility Principle by handling a specific, well-defined task. For instance, the adjust_advice_size method is solely focused on resizing the advice fields based on score ranges, while the questionnaire_factory method exclusively deals with instantiating questionnaire objects depending on their type. This separation of concerns enhances both the clarity and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP)&lt;br /&gt;
Although not immediately visible in limited code snippets, the design follows the Open/Closed Principle by being open to extension but closed to modification. For example, to support new questionnaire types, developers can extend the logic in questionnaire_factory without altering the existing structure, making the system more scalable and adaptable to future changes.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern&lt;br /&gt;
The questionnaire_factory method resembles the Factory Method Pattern by generating different types of questionnaire instances based on input parameters. This pattern enables the dynamic creation of objects without hard-coding their specific classes, improving flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
* Strategy Pattern&lt;br /&gt;
Another applicable pattern is the Strategy Pattern, especially relevant if the behavior of questionnaires (e.g., scoring, rendering, or validation) varies by type. If such behaviors are encapsulated in interchangeable classes and selected at runtime (possibly via the factory method), it aligns well with the Strategy Pattern. This promotes code reusability and simplifies the addition of new behavior types without impacting existing logic.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The adjust_advice_size method ensures that every ScoredQuestion has exactly one QuestionAdvice for each score in the range defined by its parent questionnaire. It removes advice entries outside the valid range and eliminates duplicates, while also creating missing entries for scores within range.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Create a mock or real Questionnaire instance with:&lt;br /&gt;
  min_question_score = 1&lt;br /&gt;
  max_question_score = 5&lt;br /&gt;
&lt;br /&gt;
* Create a ScoredQuestion with:&lt;br /&gt;
  id assigned&lt;br /&gt;
  question_advices association&lt;br /&gt;
&lt;br /&gt;
* Populate the QuestionAdvice table with:&lt;br /&gt;
  Advice entries within the valid range&lt;br /&gt;
  Advice entries outside the valid range&lt;br /&gt;
  Duplicate advice entries for the same score&lt;br /&gt;
&lt;br /&gt;
* Stub or use an in-memory DB to test without affecting real data.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: question is not a ScoredQuestion&lt;br /&gt;
  Should perform no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: question is a ScoredQuestion, with:&lt;br /&gt;
  Valid advice range entries → should remain untouched.&lt;br /&gt;
  Advice with scores outside [min, max] → should be deleted.&lt;br /&gt;
  Duplicate advice entries → should be reduced to one.&lt;br /&gt;
  Missing advice entries within valid range → should be created.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, the method should exit early and make no database changes.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Only one QuestionAdvice should exist for each score in [min, max].&lt;br /&gt;
  No QuestionAdvice should exist with scores outside [min, max].&lt;br /&gt;
  All newly created QuestionAdvice entries should have the correct score and question_id.&lt;br /&gt;
  The total number of QuestionAdvice entries for the question should equal (max - min + 1).&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The questionnaire_factory method is responsible for dynamically creating a new instance of a questionnaire based on a type string provided as input. It uses the QUESTIONNAIRE_MAP constant to resolve the correct class. If the type is not recognized, it sets an error message in the flash hash and returns nil.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Ensure QUESTIONNAIRE_MAP is correctly defined with mappings like:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;ReviewQuestionnaire&amp;quot; =&amp;gt; ReviewQuestionnaire,&lt;br /&gt;
  &amp;quot;SurveyQuestionnaire&amp;quot; =&amp;gt; SurveyQuestionnaire&lt;br /&gt;
  }&lt;br /&gt;
* Stub or create minimal versions of the questionnaire classes (ReviewQuestionnaire, etc.) that support .new.&lt;br /&gt;
* Mock the flash hash to observe changes when the type is invalid.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: Valid questionnaire type is provided (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;).&lt;br /&gt;
  Should return a new instance of ReviewQuestionnaire.&lt;br /&gt;
&lt;br /&gt;
* Context 2: Invalid questionnaire type is provided (e.g., &amp;quot;InvalidType&amp;quot;).&lt;br /&gt;
  Should set an error message in flash[:error].&lt;br /&gt;
  Should return nil.&lt;br /&gt;
&lt;br /&gt;
* Context 3: type is nil or an empty string.&lt;br /&gt;
  Should be treated as an invalid type.&lt;br /&gt;
  Should set flash error and return nil.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1:&lt;br /&gt;
  A new instance of the correct class is returned.&lt;br /&gt;
  No flash error is set.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  flash[:error] is set to 'Error: Undefined Questionnaire'.&lt;br /&gt;
  The method returns nil.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Same expectations as Context 2 (error set, return nil).&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The update_questionnaire_questions method updates existing Question records with new attribute values received from the request parameters. It ensures that only the changed attributes are updated and saved, thereby optimizing database writes.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ====&lt;br /&gt;
* Define params[:question] as a hash with:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;1&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Updated question text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;2&amp;quot; },&lt;br /&gt;
  &amp;quot;2&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Another text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;1&amp;quot; }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* Create corresponding Question objects with:&lt;br /&gt;
  IDs 1 and 2&lt;br /&gt;
  Initial attributes set to different values or the same (for testing updates vs no-ops)&lt;br /&gt;
&lt;br /&gt;
* Stub or set up the params object inside a test controller or context.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
* Context 1: params[:question] is nil&lt;br /&gt;
   Method should return immediately and make no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: params[:question] contains valid data&lt;br /&gt;
  Some attributes differ from the existing Question values → should update and save.&lt;br /&gt;
  Some attributes match existing values → should not update those fields.&lt;br /&gt;
&lt;br /&gt;
* Context 3: Mixed changes&lt;br /&gt;
  One Question has all new values → should be updated and saved.&lt;br /&gt;
  One Question has no changed values → should not call save.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, no Question records should be loaded or updated.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Each Question should receive updated values only for attributes that differ.&lt;br /&gt;
  question.save should be called only if at least one attribute is updated.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Only Question objects with modified attributes should trigger a .save call.&lt;br /&gt;
  Attributes already matching current values should not be re-assigned.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: 42.86%&lt;br /&gt;
* Current coverage: 100.00%&lt;br /&gt;
[[File:number_of_cases.jpg|500px]]&lt;br /&gt;
[[File:lines_covered.jpg|500px]]&lt;br /&gt;
[[File:new_code.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document presents a comprehensive strategy to improve testing and code coverage for the questionnaire_helper files in Expertiza. With clear objectives such as creating detailed test plans and scenarios, the project seeks to close existing coverage gaps. While the questionnaire_helper.rb file showed only slight improvements—mainly because the update_questionnaire_questions method was already fully covered—the focus now shifts to executing the proposed test plans to ensure robust testing and reliability across all key functionalities in both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
* GitHub Pull Request: [https://github.com/expertiza/expertiza/pull/2950 Pull Request]&lt;br /&gt;
* GitHub Repository: [https://github.com/ishani-rajput/expertiza Github]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=164407</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=164407"/>
		<updated>2025-04-22T00:04:03Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2529. Testing for the Questionnaire Helper in Expertiza&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project focuses on developing test cases for the questionnaire_helper module within Expertiza, an open-source assignment and project management system built using Ruby on Rails. The platform supports collaborative learning by enabling instructors to design assignments, set up topics for sign-up, and organize student teams. Meanwhile, students can choose topics, work in groups, and engage in peer assessments to support each other's learning. The primary aim of this project is to create thorough test plans and improve code coverage for these helper modules, ensuring their functionality and dependability within the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi (pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Dependency Injection Principle (DIP)&lt;br /&gt;
The QuestionnaireHelper methods accept objects like questionnaire or scored_question as parameters rather than instantiating them internally. This reflects the Dependency Injection Principle, promoting loose coupling. It also makes the methods easier to test and reuse, since dependencies are provided externally and can be mocked or substituted as needed.&lt;br /&gt;
&lt;br /&gt;
* Single Responsibility Principle (SRP)&lt;br /&gt;
Each method in the QuestionnaireHelper module demonstrates the Single Responsibility Principle by handling a specific, well-defined task. For instance, the adjust_advice_size method is solely focused on resizing the advice fields based on score ranges, while the questionnaire_factory method exclusively deals with instantiating questionnaire objects depending on their type. This separation of concerns enhances both the clarity and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP)&lt;br /&gt;
Although not immediately visible in limited code snippets, the design follows the Open/Closed Principle by being open to extension but closed to modification. For example, to support new questionnaire types, developers can extend the logic in questionnaire_factory without altering the existing structure, making the system more scalable and adaptable to future changes.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern&lt;br /&gt;
The questionnaire_factory method resembles the Factory Method Pattern by generating different types of questionnaire instances based on input parameters. This pattern enables the dynamic creation of objects without hard-coding their specific classes, improving flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
* Strategy Pattern&lt;br /&gt;
Another applicable pattern is the Strategy Pattern, especially relevant if the behavior of questionnaires (e.g., scoring, rendering, or validation) varies by type. If such behaviors are encapsulated in interchangeable classes and selected at runtime (possibly via the factory method), it aligns well with the Strategy Pattern. This promotes code reusability and simplifies the addition of new behavior types without impacting existing logic.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The adjust_advice_size method ensures that every ScoredQuestion has exactly one QuestionAdvice for each score in the range defined by its parent questionnaire. It removes advice entries outside the valid range and eliminates duplicates, while also creating missing entries for scores within range.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Create a mock or real Questionnaire instance with:&lt;br /&gt;
  min_question_score = 1&lt;br /&gt;
  max_question_score = 5&lt;br /&gt;
&lt;br /&gt;
* Create a ScoredQuestion with:&lt;br /&gt;
  id assigned&lt;br /&gt;
  question_advices association&lt;br /&gt;
&lt;br /&gt;
* Populate the QuestionAdvice table with:&lt;br /&gt;
  Advice entries within the valid range&lt;br /&gt;
  Advice entries outside the valid range&lt;br /&gt;
  Duplicate advice entries for the same score&lt;br /&gt;
&lt;br /&gt;
* Stub or use an in-memory DB to test without affecting real data.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: question is not a ScoredQuestion&lt;br /&gt;
  Should perform no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: question is a ScoredQuestion, with:&lt;br /&gt;
  Valid advice range entries → should remain untouched.&lt;br /&gt;
  Advice with scores outside [min, max] → should be deleted.&lt;br /&gt;
  Duplicate advice entries → should be reduced to one.&lt;br /&gt;
  Missing advice entries within valid range → should be created.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, the method should exit early and make no database changes.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Only one QuestionAdvice should exist for each score in [min, max].&lt;br /&gt;
  No QuestionAdvice should exist with scores outside [min, max].&lt;br /&gt;
  All newly created QuestionAdvice entries should have the correct score and question_id.&lt;br /&gt;
  The total number of QuestionAdvice entries for the question should equal (max - min + 1).&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The questionnaire_factory method is responsible for dynamically creating a new instance of a questionnaire based on a type string provided as input. It uses the QUESTIONNAIRE_MAP constant to resolve the correct class. If the type is not recognized, it sets an error message in the flash hash and returns nil.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Ensure QUESTIONNAIRE_MAP is correctly defined with mappings like:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;ReviewQuestionnaire&amp;quot; =&amp;gt; ReviewQuestionnaire,&lt;br /&gt;
  &amp;quot;SurveyQuestionnaire&amp;quot; =&amp;gt; SurveyQuestionnaire&lt;br /&gt;
  }&lt;br /&gt;
* Stub or create minimal versions of the questionnaire classes (ReviewQuestionnaire, etc.) that support .new.&lt;br /&gt;
* Mock the flash hash to observe changes when the type is invalid.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: Valid questionnaire type is provided (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;).&lt;br /&gt;
  Should return a new instance of ReviewQuestionnaire.&lt;br /&gt;
&lt;br /&gt;
* Context 2: Invalid questionnaire type is provided (e.g., &amp;quot;InvalidType&amp;quot;).&lt;br /&gt;
  Should set an error message in flash[:error].&lt;br /&gt;
  Should return nil.&lt;br /&gt;
&lt;br /&gt;
* Context 3: type is nil or an empty string.&lt;br /&gt;
  Should be treated as an invalid type.&lt;br /&gt;
  Should set flash error and return nil.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1:&lt;br /&gt;
  A new instance of the correct class is returned.&lt;br /&gt;
  No flash error is set.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  flash[:error] is set to 'Error: Undefined Questionnaire'.&lt;br /&gt;
  The method returns nil.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Same expectations as Context 2 (error set, return nil).&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The update_questionnaire_questions method updates existing Question records with new attribute values received from the request parameters. It ensures that only the changed attributes are updated and saved, thereby optimizing database writes.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ====&lt;br /&gt;
* Define params[:question] as a hash with:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;1&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Updated question text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;2&amp;quot; },&lt;br /&gt;
  &amp;quot;2&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Another text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;1&amp;quot; }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* Create corresponding Question objects with:&lt;br /&gt;
  IDs 1 and 2&lt;br /&gt;
  Initial attributes set to different values or the same (for testing updates vs no-ops)&lt;br /&gt;
&lt;br /&gt;
* Stub or set up the params object inside a test controller or context.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
* Context 1: params[:question] is nil&lt;br /&gt;
   Method should return immediately and make no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: params[:question] contains valid data&lt;br /&gt;
  Some attributes differ from the existing Question values → should update and save.&lt;br /&gt;
  Some attributes match existing values → should not update those fields.&lt;br /&gt;
&lt;br /&gt;
* Context 3: Mixed changes&lt;br /&gt;
  One Question has all new values → should be updated and saved.&lt;br /&gt;
  One Question has no changed values → should not call save.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, no Question records should be loaded or updated.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Each Question should receive updated values only for attributes that differ.&lt;br /&gt;
  question.save should be called only if at least one attribute is updated.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Only Question objects with modified attributes should trigger a .save call.&lt;br /&gt;
  Attributes already matching current values should not be re-assigned.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: 42.86%&lt;br /&gt;
* Current coverage: 100.00%&lt;br /&gt;
[[File:number_of_cases.jpg]]&lt;br /&gt;
[[File:lines_covered.jpg]]&lt;br /&gt;
[[File:new_code.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document presents a comprehensive strategy to improve testing and code coverage for the questionnaire_helper files in Expertiza. With clear objectives such as creating detailed test plans and scenarios, the project seeks to close existing coverage gaps. While the questionnaire_helper.rb file showed only slight improvements—mainly because the update_questionnaire_questions method was already fully covered—the focus now shifts to executing the proposed test plans to ensure robust testing and reliability across all key functionalities in both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
* GitHub Pull Request: [https://github.com/expertiza/expertiza/pull/2950 Pull Request]&lt;br /&gt;
* GitHub Repository: [https://github.com/ishani-rajput/expertiza Github]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:New_code.jpg&amp;diff=164405</id>
		<title>File:New code.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:New_code.jpg&amp;diff=164405"/>
		<updated>2025-04-22T00:01:44Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Lines_covered.jpg&amp;diff=164404</id>
		<title>File:Lines covered.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Lines_covered.jpg&amp;diff=164404"/>
		<updated>2025-04-22T00:01:07Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=164403</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=164403"/>
		<updated>2025-04-21T23:59:44Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2529. Testing for the Questionnaire Helper in Expertiza&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project focuses on developing test cases for the questionnaire_helper module within Expertiza, an open-source assignment and project management system built using Ruby on Rails. The platform supports collaborative learning by enabling instructors to design assignments, set up topics for sign-up, and organize student teams. Meanwhile, students can choose topics, work in groups, and engage in peer assessments to support each other's learning. The primary aim of this project is to create thorough test plans and improve code coverage for these helper modules, ensuring their functionality and dependability within the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi (pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Dependency Injection Principle (DIP)&lt;br /&gt;
The QuestionnaireHelper methods accept objects like questionnaire or scored_question as parameters rather than instantiating them internally. This reflects the Dependency Injection Principle, promoting loose coupling. It also makes the methods easier to test and reuse, since dependencies are provided externally and can be mocked or substituted as needed.&lt;br /&gt;
&lt;br /&gt;
* Single Responsibility Principle (SRP)&lt;br /&gt;
Each method in the QuestionnaireHelper module demonstrates the Single Responsibility Principle by handling a specific, well-defined task. For instance, the adjust_advice_size method is solely focused on resizing the advice fields based on score ranges, while the questionnaire_factory method exclusively deals with instantiating questionnaire objects depending on their type. This separation of concerns enhances both the clarity and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP)&lt;br /&gt;
Although not immediately visible in limited code snippets, the design follows the Open/Closed Principle by being open to extension but closed to modification. For example, to support new questionnaire types, developers can extend the logic in questionnaire_factory without altering the existing structure, making the system more scalable and adaptable to future changes.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern&lt;br /&gt;
The questionnaire_factory method resembles the Factory Method Pattern by generating different types of questionnaire instances based on input parameters. This pattern enables the dynamic creation of objects without hard-coding their specific classes, improving flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
* Strategy Pattern&lt;br /&gt;
Another applicable pattern is the Strategy Pattern, especially relevant if the behavior of questionnaires (e.g., scoring, rendering, or validation) varies by type. If such behaviors are encapsulated in interchangeable classes and selected at runtime (possibly via the factory method), it aligns well with the Strategy Pattern. This promotes code reusability and simplifies the addition of new behavior types without impacting existing logic.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The adjust_advice_size method ensures that every ScoredQuestion has exactly one QuestionAdvice for each score in the range defined by its parent questionnaire. It removes advice entries outside the valid range and eliminates duplicates, while also creating missing entries for scores within range.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Create a mock or real Questionnaire instance with:&lt;br /&gt;
  min_question_score = 1&lt;br /&gt;
  max_question_score = 5&lt;br /&gt;
&lt;br /&gt;
* Create a ScoredQuestion with:&lt;br /&gt;
  id assigned&lt;br /&gt;
  question_advices association&lt;br /&gt;
&lt;br /&gt;
* Populate the QuestionAdvice table with:&lt;br /&gt;
  Advice entries within the valid range&lt;br /&gt;
  Advice entries outside the valid range&lt;br /&gt;
  Duplicate advice entries for the same score&lt;br /&gt;
&lt;br /&gt;
* Stub or use an in-memory DB to test without affecting real data.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: question is not a ScoredQuestion&lt;br /&gt;
  Should perform no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: question is a ScoredQuestion, with:&lt;br /&gt;
  Valid advice range entries → should remain untouched.&lt;br /&gt;
  Advice with scores outside [min, max] → should be deleted.&lt;br /&gt;
  Duplicate advice entries → should be reduced to one.&lt;br /&gt;
  Missing advice entries within valid range → should be created.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, the method should exit early and make no database changes.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Only one QuestionAdvice should exist for each score in [min, max].&lt;br /&gt;
  No QuestionAdvice should exist with scores outside [min, max].&lt;br /&gt;
  All newly created QuestionAdvice entries should have the correct score and question_id.&lt;br /&gt;
  The total number of QuestionAdvice entries for the question should equal (max - min + 1).&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The questionnaire_factory method is responsible for dynamically creating a new instance of a questionnaire based on a type string provided as input. It uses the QUESTIONNAIRE_MAP constant to resolve the correct class. If the type is not recognized, it sets an error message in the flash hash and returns nil.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Ensure QUESTIONNAIRE_MAP is correctly defined with mappings like:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;ReviewQuestionnaire&amp;quot; =&amp;gt; ReviewQuestionnaire,&lt;br /&gt;
  &amp;quot;SurveyQuestionnaire&amp;quot; =&amp;gt; SurveyQuestionnaire&lt;br /&gt;
  }&lt;br /&gt;
* Stub or create minimal versions of the questionnaire classes (ReviewQuestionnaire, etc.) that support .new.&lt;br /&gt;
* Mock the flash hash to observe changes when the type is invalid.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: Valid questionnaire type is provided (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;).&lt;br /&gt;
  Should return a new instance of ReviewQuestionnaire.&lt;br /&gt;
&lt;br /&gt;
* Context 2: Invalid questionnaire type is provided (e.g., &amp;quot;InvalidType&amp;quot;).&lt;br /&gt;
  Should set an error message in flash[:error].&lt;br /&gt;
  Should return nil.&lt;br /&gt;
&lt;br /&gt;
* Context 3: type is nil or an empty string.&lt;br /&gt;
  Should be treated as an invalid type.&lt;br /&gt;
  Should set flash error and return nil.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1:&lt;br /&gt;
  A new instance of the correct class is returned.&lt;br /&gt;
  No flash error is set.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  flash[:error] is set to 'Error: Undefined Questionnaire'.&lt;br /&gt;
  The method returns nil.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Same expectations as Context 2 (error set, return nil).&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The update_questionnaire_questions method updates existing Question records with new attribute values received from the request parameters. It ensures that only the changed attributes are updated and saved, thereby optimizing database writes.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ====&lt;br /&gt;
* Define params[:question] as a hash with:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;1&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Updated question text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;2&amp;quot; },&lt;br /&gt;
  &amp;quot;2&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Another text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;1&amp;quot; }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* Create corresponding Question objects with:&lt;br /&gt;
  IDs 1 and 2&lt;br /&gt;
  Initial attributes set to different values or the same (for testing updates vs no-ops)&lt;br /&gt;
&lt;br /&gt;
* Stub or set up the params object inside a test controller or context.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
* Context 1: params[:question] is nil&lt;br /&gt;
   Method should return immediately and make no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: params[:question] contains valid data&lt;br /&gt;
  Some attributes differ from the existing Question values → should update and save.&lt;br /&gt;
  Some attributes match existing values → should not update those fields.&lt;br /&gt;
&lt;br /&gt;
* Context 3: Mixed changes&lt;br /&gt;
  One Question has all new values → should be updated and saved.&lt;br /&gt;
  One Question has no changed values → should not call save.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, no Question records should be loaded or updated.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Each Question should receive updated values only for attributes that differ.&lt;br /&gt;
  question.save should be called only if at least one attribute is updated.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Only Question objects with modified attributes should trigger a .save call.&lt;br /&gt;
  Attributes already matching current values should not be re-assigned.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: 42.86%&lt;br /&gt;
* Current coverage: 100.00%&lt;br /&gt;
[[File:number_of_cases.png]]&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document presents a comprehensive strategy to improve testing and code coverage for the questionnaire_helper files in Expertiza. With clear objectives such as creating detailed test plans and scenarios, the project seeks to close existing coverage gaps. While the questionnaire_helper.rb file showed only slight improvements—mainly because the update_questionnaire_questions method was already fully covered—the focus now shifts to executing the proposed test plans to ensure robust testing and reliability across all key functionalities in both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
* GitHub Pull Request: [https://github.com/expertiza/expertiza/pull/2950 Pull Request]&lt;br /&gt;
* GitHub Repository: [https://github.com/ishani-rajput/expertiza Github]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163847</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163847"/>
		<updated>2025-04-08T03:17:01Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2529. Testing for the Questionnaire Helper in Expertiza&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project focuses on developing test cases for the questionnaire_helper module within Expertiza, an open-source assignment and project management system built using Ruby on Rails. The platform supports collaborative learning by enabling instructors to design assignments, set up topics for sign-up, and organize student teams. Meanwhile, students can choose topics, work in groups, and engage in peer assessments to support each other's learning. The primary aim of this project is to create thorough test plans and improve code coverage for these helper modules, ensuring their functionality and dependability within the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Current Code Coverage ===&lt;br /&gt;
* Questionnaire_helper: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi (pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Dependency Injection Principle (DIP)&lt;br /&gt;
The QuestionnaireHelper methods accept objects like questionnaire or scored_question as parameters rather than instantiating them internally. This reflects the Dependency Injection Principle, promoting loose coupling. It also makes the methods easier to test and reuse, since dependencies are provided externally and can be mocked or substituted as needed.&lt;br /&gt;
&lt;br /&gt;
* Single Responsibility Principle (SRP)&lt;br /&gt;
Each method in the QuestionnaireHelper module demonstrates the Single Responsibility Principle by handling a specific, well-defined task. For instance, the adjust_advice_size method is solely focused on resizing the advice fields based on score ranges, while the questionnaire_factory method exclusively deals with instantiating questionnaire objects depending on their type. This separation of concerns enhances both the clarity and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP)&lt;br /&gt;
Although not immediately visible in limited code snippets, the design follows the Open/Closed Principle by being open to extension but closed to modification. For example, to support new questionnaire types, developers can extend the logic in questionnaire_factory without altering the existing structure, making the system more scalable and adaptable to future changes.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern&lt;br /&gt;
The questionnaire_factory method resembles the Factory Method Pattern by generating different types of questionnaire instances based on input parameters. This pattern enables the dynamic creation of objects without hard-coding their specific classes, improving flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
* Strategy Pattern&lt;br /&gt;
Another applicable pattern is the Strategy Pattern, especially relevant if the behavior of questionnaires (e.g., scoring, rendering, or validation) varies by type. If such behaviors are encapsulated in interchangeable classes and selected at runtime (possibly via the factory method), it aligns well with the Strategy Pattern. This promotes code reusability and simplifies the addition of new behavior types without impacting existing logic.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The adjust_advice_size method ensures that every ScoredQuestion has exactly one QuestionAdvice for each score in the range defined by its parent questionnaire. It removes advice entries outside the valid range and eliminates duplicates, while also creating missing entries for scores within range.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Create a mock or real Questionnaire instance with:&lt;br /&gt;
  min_question_score = 1&lt;br /&gt;
  max_question_score = 5&lt;br /&gt;
&lt;br /&gt;
* Create a ScoredQuestion with:&lt;br /&gt;
  id assigned&lt;br /&gt;
  question_advices association&lt;br /&gt;
&lt;br /&gt;
* Populate the QuestionAdvice table with:&lt;br /&gt;
  Advice entries within the valid range&lt;br /&gt;
  Advice entries outside the valid range&lt;br /&gt;
  Duplicate advice entries for the same score&lt;br /&gt;
&lt;br /&gt;
* Stub or use an in-memory DB to test without affecting real data.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: question is not a ScoredQuestion&lt;br /&gt;
  Should perform no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: question is a ScoredQuestion, with:&lt;br /&gt;
  Valid advice range entries → should remain untouched.&lt;br /&gt;
  Advice with scores outside [min, max] → should be deleted.&lt;br /&gt;
  Duplicate advice entries → should be reduced to one.&lt;br /&gt;
  Missing advice entries within valid range → should be created.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, the method should exit early and make no database changes.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Only one QuestionAdvice should exist for each score in [min, max].&lt;br /&gt;
  No QuestionAdvice should exist with scores outside [min, max].&lt;br /&gt;
  All newly created QuestionAdvice entries should have the correct score and question_id.&lt;br /&gt;
  The total number of QuestionAdvice entries for the question should equal (max - min + 1).&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The questionnaire_factory method is responsible for dynamically creating a new instance of a questionnaire based on a type string provided as input. It uses the QUESTIONNAIRE_MAP constant to resolve the correct class. If the type is not recognized, it sets an error message in the flash hash and returns nil.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Ensure QUESTIONNAIRE_MAP is correctly defined with mappings like:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;ReviewQuestionnaire&amp;quot; =&amp;gt; ReviewQuestionnaire,&lt;br /&gt;
  &amp;quot;SurveyQuestionnaire&amp;quot; =&amp;gt; SurveyQuestionnaire&lt;br /&gt;
  }&lt;br /&gt;
* Stub or create minimal versions of the questionnaire classes (ReviewQuestionnaire, etc.) that support .new.&lt;br /&gt;
* Mock the flash hash to observe changes when the type is invalid.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: Valid questionnaire type is provided (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;).&lt;br /&gt;
  Should return a new instance of ReviewQuestionnaire.&lt;br /&gt;
&lt;br /&gt;
* Context 2: Invalid questionnaire type is provided (e.g., &amp;quot;InvalidType&amp;quot;).&lt;br /&gt;
  Should set an error message in flash[:error].&lt;br /&gt;
  Should return nil.&lt;br /&gt;
&lt;br /&gt;
* Context 3: type is nil or an empty string.&lt;br /&gt;
  Should be treated as an invalid type.&lt;br /&gt;
  Should set flash error and return nil.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1:&lt;br /&gt;
  A new instance of the correct class is returned.&lt;br /&gt;
  No flash error is set.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  flash[:error] is set to 'Error: Undefined Questionnaire'.&lt;br /&gt;
  The method returns nil.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Same expectations as Context 2 (error set, return nil).&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The update_questionnaire_questions method updates existing Question records with new attribute values received from the request parameters. It ensures that only the changed attributes are updated and saved, thereby optimizing database writes.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ====&lt;br /&gt;
* Define params[:question] as a hash with:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;1&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Updated question text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;2&amp;quot; },&lt;br /&gt;
  &amp;quot;2&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Another text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;1&amp;quot; }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* Create corresponding Question objects with:&lt;br /&gt;
  IDs 1 and 2&lt;br /&gt;
  Initial attributes set to different values or the same (for testing updates vs no-ops)&lt;br /&gt;
&lt;br /&gt;
* Stub or set up the params object inside a test controller or context.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
* Context 1: params[:question] is nil&lt;br /&gt;
   Method should return immediately and make no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: params[:question] contains valid data&lt;br /&gt;
  Some attributes differ from the existing Question values → should update and save.&lt;br /&gt;
  Some attributes match existing values → should not update those fields.&lt;br /&gt;
&lt;br /&gt;
* Context 3: Mixed changes&lt;br /&gt;
  One Question has all new values → should be updated and saved.&lt;br /&gt;
  One Question has no changed values → should not call save.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, no Question records should be loaded or updated.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Each Question should receive updated values only for attributes that differ.&lt;br /&gt;
  question.save should be called only if at least one attribute is updated.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Only Question objects with modified attributes should trigger a .save call.&lt;br /&gt;
  Attributes already matching current values should not be re-assigned.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: TBD after implementation&lt;br /&gt;
* Current coverage: TBD after implementation&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document presents a comprehensive strategy to improve testing and code coverage for the questionnaire_helper files in Expertiza. With clear objectives such as creating detailed test plans and scenarios, the project seeks to close existing coverage gaps. While the questionnaire_helper.rb file showed only slight improvements—mainly because the update_questionnaire_questions method was already fully covered—the focus now shifts to executing the proposed test plans to ensure robust testing and reliability across all key functionalities in both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
* Github Pull Request: [https://github.com/expertiza/expertiza/pull/2950 Pull Request]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163840</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163840"/>
		<updated>2025-04-08T03:14:18Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: /* Questionnaire_helper */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2529. Testing for the Questionnaire Helper in Expertiza&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project focuses on developing test cases for the questionnaire_helper module within Expertiza, an open-source assignment and project management system built using Ruby on Rails. The platform supports collaborative learning by enabling instructors to design assignments, set up topics for sign-up, and organize student teams. Meanwhile, students can choose topics, work in groups, and engage in peer assessments to support each other's learning. The primary aim of this project is to create thorough test plans and improve code coverage for these helper modules, ensuring their functionality and dependability within the Expertiza system.&lt;br /&gt;
&lt;br /&gt;
=== Current Code Coverage ===&lt;br /&gt;
* Questionnaire_helper: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi (pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Dependency Injection Principle (DIP)&lt;br /&gt;
The QuestionnaireHelper methods accept objects like questionnaire or scored_question as parameters rather than instantiating them internally. This reflects the Dependency Injection Principle, promoting loose coupling. It also makes the methods easier to test and reuse, since dependencies are provided externally and can be mocked or substituted as needed.&lt;br /&gt;
&lt;br /&gt;
* Single Responsibility Principle (SRP)&lt;br /&gt;
Each method in the QuestionnaireHelper module demonstrates the Single Responsibility Principle by handling a specific, well-defined task. For instance, the adjust_advice_size method is solely focused on resizing the advice fields based on score ranges, while the questionnaire_factory method exclusively deals with instantiating questionnaire objects depending on their type. This separation of concerns enhances both the clarity and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP)&lt;br /&gt;
Although not immediately visible in limited code snippets, the design follows the Open/Closed Principle by being open to extension but closed to modification. For example, to support new questionnaire types, developers can extend the logic in questionnaire_factory without altering the existing structure, making the system more scalable and adaptable to future changes.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern&lt;br /&gt;
The questionnaire_factory method resembles the Factory Method Pattern by generating different types of questionnaire instances based on input parameters. This pattern enables the dynamic creation of objects without hard-coding their specific classes, improving flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
* Strategy Pattern&lt;br /&gt;
Another applicable pattern is the Strategy Pattern, especially relevant if the behavior of questionnaires (e.g., scoring, rendering, or validation) varies by type. If such behaviors are encapsulated in interchangeable classes and selected at runtime (possibly via the factory method), it aligns well with the Strategy Pattern. This promotes code reusability and simplifies the addition of new behavior types without impacting existing logic.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The adjust_advice_size method ensures that every ScoredQuestion has exactly one QuestionAdvice for each score in the range defined by its parent questionnaire. It removes advice entries outside the valid range and eliminates duplicates, while also creating missing entries for scores within range.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Create a mock or real Questionnaire instance with:&lt;br /&gt;
  min_question_score = 1&lt;br /&gt;
  max_question_score = 5&lt;br /&gt;
&lt;br /&gt;
* Create a ScoredQuestion with:&lt;br /&gt;
  id assigned&lt;br /&gt;
  question_advices association&lt;br /&gt;
&lt;br /&gt;
* Populate the QuestionAdvice table with:&lt;br /&gt;
  Advice entries within the valid range&lt;br /&gt;
  Advice entries outside the valid range&lt;br /&gt;
  Duplicate advice entries for the same score&lt;br /&gt;
&lt;br /&gt;
* Stub or use an in-memory DB to test without affecting real data.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: question is not a ScoredQuestion&lt;br /&gt;
  Should perform no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: question is a ScoredQuestion, with:&lt;br /&gt;
  Valid advice range entries → should remain untouched.&lt;br /&gt;
  Advice with scores outside [min, max] → should be deleted.&lt;br /&gt;
  Duplicate advice entries → should be reduced to one.&lt;br /&gt;
  Missing advice entries within valid range → should be created.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, the method should exit early and make no database changes.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Only one QuestionAdvice should exist for each score in [min, max].&lt;br /&gt;
  No QuestionAdvice should exist with scores outside [min, max].&lt;br /&gt;
  All newly created QuestionAdvice entries should have the correct score and question_id.&lt;br /&gt;
  The total number of QuestionAdvice entries for the question should equal (max - min + 1).&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The questionnaire_factory method is responsible for dynamically creating a new instance of a questionnaire based on a type string provided as input. It uses the QUESTIONNAIRE_MAP constant to resolve the correct class. If the type is not recognized, it sets an error message in the flash hash and returns nil.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Ensure QUESTIONNAIRE_MAP is correctly defined with mappings like:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;ReviewQuestionnaire&amp;quot; =&amp;gt; ReviewQuestionnaire,&lt;br /&gt;
  &amp;quot;SurveyQuestionnaire&amp;quot; =&amp;gt; SurveyQuestionnaire&lt;br /&gt;
  }&lt;br /&gt;
* Stub or create minimal versions of the questionnaire classes (ReviewQuestionnaire, etc.) that support .new.&lt;br /&gt;
* Mock the flash hash to observe changes when the type is invalid.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: Valid questionnaire type is provided (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;).&lt;br /&gt;
  Should return a new instance of ReviewQuestionnaire.&lt;br /&gt;
&lt;br /&gt;
* Context 2: Invalid questionnaire type is provided (e.g., &amp;quot;InvalidType&amp;quot;).&lt;br /&gt;
  Should set an error message in flash[:error].&lt;br /&gt;
  Should return nil.&lt;br /&gt;
&lt;br /&gt;
* Context 3: type is nil or an empty string.&lt;br /&gt;
  Should be treated as an invalid type.&lt;br /&gt;
  Should set flash error and return nil.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1:&lt;br /&gt;
  A new instance of the correct class is returned.&lt;br /&gt;
  No flash error is set.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  flash[:error] is set to 'Error: Undefined Questionnaire'.&lt;br /&gt;
  The method returns nil.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Same expectations as Context 2 (error set, return nil).&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The update_questionnaire_questions method updates existing Question records with new attribute values received from the request parameters. It ensures that only the changed attributes are updated and saved, thereby optimizing database writes.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ====&lt;br /&gt;
* Define params[:question] as a hash with:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;1&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Updated question text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;2&amp;quot; },&lt;br /&gt;
  &amp;quot;2&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Another text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;1&amp;quot; }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* Create corresponding Question objects with:&lt;br /&gt;
  IDs 1 and 2&lt;br /&gt;
  Initial attributes set to different values or the same (for testing updates vs no-ops)&lt;br /&gt;
&lt;br /&gt;
* Stub or set up the params object inside a test controller or context.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
* Context 1: params[:question] is nil&lt;br /&gt;
   Method should return immediately and make no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: params[:question] contains valid data&lt;br /&gt;
  Some attributes differ from the existing Question values → should update and save.&lt;br /&gt;
  Some attributes match existing values → should not update those fields.&lt;br /&gt;
&lt;br /&gt;
* Context 3: Mixed changes&lt;br /&gt;
  One Question has all new values → should be updated and saved.&lt;br /&gt;
  One Question has no changed values → should not call save.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, no Question records should be loaded or updated.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Each Question should receive updated values only for attributes that differ.&lt;br /&gt;
  question.save should be called only if at least one attribute is updated.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Only Question objects with modified attributes should trigger a .save call.&lt;br /&gt;
  Attributes already matching current values should not be re-assigned.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: TBD after implementation&lt;br /&gt;
* Current coverage: TBD after implementation&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document outlines a thorough plan to enhance testing and code coverage for the questionnaire_helper files in Expertiza. With defined objectives, including developing detailed test plans and scenarios, the project aims to address current code coverage gaps. Conversely, the questionnaire_helper.rb file saw marginal improvements, primarily due to existing full coverage in the update_questionnaire_questions method. Moving forward, the project will focus on implementing the outlined test plans, ensuring comprehensive testing and reliability for critical functionality across both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
* Github Pull Request: [https://github.com/expertiza/expertiza/pull/2950 Pull Request]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163824</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163824"/>
		<updated>2025-04-08T03:06:42Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2529. Testing for the Questionnaire Helper in Expertiza&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project involves writing test cases for the `questionnaire_helper` and `review_bids_helper` files in Expertiza, an open-source assignment/project management portal built on the Ruby on Rails framework. This platform facilitates collaborative learning and feedback among both instructors and students. Instructors can create and customize assignments, define topics for student sign-ups, and manage teams for various projects. Students, on the other hand, can sign up for topics, form teams, and participate in peer reviews to enhance each other's learning experiences. Our goal is to develop comprehensive test plans and increase code coverage for these helper files to ensure their reliability and effectiveness in the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Current Code Coverage ===&lt;br /&gt;
* Questionnaire_helper: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi (pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Dependency Injection Principle (DIP)&lt;br /&gt;
The QuestionnaireHelper methods accept objects like questionnaire or scored_question as parameters rather than instantiating them internally. This reflects the Dependency Injection Principle, promoting loose coupling. It also makes the methods easier to test and reuse, since dependencies are provided externally and can be mocked or substituted as needed.&lt;br /&gt;
&lt;br /&gt;
* Single Responsibility Principle (SRP)&lt;br /&gt;
Each method in the QuestionnaireHelper module demonstrates the Single Responsibility Principle by handling a specific, well-defined task. For instance, the adjust_advice_size method is solely focused on resizing the advice fields based on score ranges, while the questionnaire_factory method exclusively deals with instantiating questionnaire objects depending on their type. This separation of concerns enhances both the clarity and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP)&lt;br /&gt;
Although not immediately visible in limited code snippets, the design follows the Open/Closed Principle by being open to extension but closed to modification. For example, to support new questionnaire types, developers can extend the logic in questionnaire_factory without altering the existing structure, making the system more scalable and adaptable to future changes.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern&lt;br /&gt;
The questionnaire_factory method resembles the Factory Method Pattern by generating different types of questionnaire instances based on input parameters. This pattern enables the dynamic creation of objects without hard-coding their specific classes, improving flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
* Strategy Pattern&lt;br /&gt;
Another applicable pattern is the Strategy Pattern, especially relevant if the behavior of questionnaires (e.g., scoring, rendering, or validation) varies by type. If such behaviors are encapsulated in interchangeable classes and selected at runtime (possibly via the factory method), it aligns well with the Strategy Pattern. This promotes code reusability and simplifies the addition of new behavior types without impacting existing logic.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The adjust_advice_size method ensures that every ScoredQuestion has exactly one QuestionAdvice for each score in the range defined by its parent questionnaire. It removes advice entries outside the valid range and eliminates duplicates, while also creating missing entries for scores within range.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Create a mock or real Questionnaire instance with:&lt;br /&gt;
  min_question_score = 1&lt;br /&gt;
  max_question_score = 5&lt;br /&gt;
&lt;br /&gt;
* Create a ScoredQuestion with:&lt;br /&gt;
  id assigned&lt;br /&gt;
  question_advices association&lt;br /&gt;
&lt;br /&gt;
* Populate the QuestionAdvice table with:&lt;br /&gt;
  Advice entries within the valid range&lt;br /&gt;
  Advice entries outside the valid range&lt;br /&gt;
  Duplicate advice entries for the same score&lt;br /&gt;
&lt;br /&gt;
* Stub or use an in-memory DB to test without affecting real data.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: question is not a ScoredQuestion&lt;br /&gt;
  Should perform no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: question is a ScoredQuestion, with:&lt;br /&gt;
  Valid advice range entries → should remain untouched.&lt;br /&gt;
  Advice with scores outside [min, max] → should be deleted.&lt;br /&gt;
  Duplicate advice entries → should be reduced to one.&lt;br /&gt;
  Missing advice entries within valid range → should be created.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, the method should exit early and make no database changes.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Only one QuestionAdvice should exist for each score in [min, max].&lt;br /&gt;
  No QuestionAdvice should exist with scores outside [min, max].&lt;br /&gt;
  All newly created QuestionAdvice entries should have the correct score and question_id.&lt;br /&gt;
  The total number of QuestionAdvice entries for the question should equal (max - min + 1).&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The questionnaire_factory method is responsible for dynamically creating a new instance of a questionnaire based on a type string provided as input. It uses the QUESTIONNAIRE_MAP constant to resolve the correct class. If the type is not recognized, it sets an error message in the flash hash and returns nil.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Ensure QUESTIONNAIRE_MAP is correctly defined with mappings like:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;ReviewQuestionnaire&amp;quot; =&amp;gt; ReviewQuestionnaire,&lt;br /&gt;
  &amp;quot;SurveyQuestionnaire&amp;quot; =&amp;gt; SurveyQuestionnaire&lt;br /&gt;
  }&lt;br /&gt;
* Stub or create minimal versions of the questionnaire classes (ReviewQuestionnaire, etc.) that support .new.&lt;br /&gt;
* Mock the flash hash to observe changes when the type is invalid.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: Valid questionnaire type is provided (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;).&lt;br /&gt;
  Should return a new instance of ReviewQuestionnaire.&lt;br /&gt;
&lt;br /&gt;
* Context 2: Invalid questionnaire type is provided (e.g., &amp;quot;InvalidType&amp;quot;).&lt;br /&gt;
  Should set an error message in flash[:error].&lt;br /&gt;
  Should return nil.&lt;br /&gt;
&lt;br /&gt;
* Context 3: type is nil or an empty string.&lt;br /&gt;
  Should be treated as an invalid type.&lt;br /&gt;
  Should set flash error and return nil.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1:&lt;br /&gt;
  A new instance of the correct class is returned.&lt;br /&gt;
  No flash error is set.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  flash[:error] is set to 'Error: Undefined Questionnaire'.&lt;br /&gt;
  The method returns nil.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Same expectations as Context 2 (error set, return nil).&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The update_questionnaire_questions method updates existing Question records with new attribute values received from the request parameters. It ensures that only the changed attributes are updated and saved, thereby optimizing database writes.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ====&lt;br /&gt;
* Define params[:question] as a hash with:&lt;br /&gt;
  {&lt;br /&gt;
  &amp;quot;1&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Updated question text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;2&amp;quot; },&lt;br /&gt;
  &amp;quot;2&amp;quot; =&amp;gt; { &amp;quot;txt&amp;quot; =&amp;gt; &amp;quot;Another text&amp;quot;, &amp;quot;weight&amp;quot; =&amp;gt; &amp;quot;1&amp;quot; }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* Create corresponding Question objects with:&lt;br /&gt;
  IDs 1 and 2&lt;br /&gt;
  Initial attributes set to different values or the same (for testing updates vs no-ops)&lt;br /&gt;
&lt;br /&gt;
* Stub or set up the params object inside a test controller or context.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
* Context 1: params[:question] is nil&lt;br /&gt;
   Method should return immediately and make no changes.&lt;br /&gt;
&lt;br /&gt;
* Context 2: params[:question] contains valid data&lt;br /&gt;
  Some attributes differ from the existing Question values → should update and save.&lt;br /&gt;
  Some attributes match existing values → should not update those fields.&lt;br /&gt;
&lt;br /&gt;
* Context 3: Mixed changes&lt;br /&gt;
  One Question has all new values → should be updated and saved.&lt;br /&gt;
  One Question has no changed values → should not call save.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, no Question records should be loaded or updated.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Each Question should receive updated values only for attributes that differ.&lt;br /&gt;
  question.save should be called only if at least one attribute is updated.&lt;br /&gt;
* In Context 3:&lt;br /&gt;
  Only Question objects with modified attributes should trigger a .save call.&lt;br /&gt;
  Attributes already matching current values should not be re-assigned.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: &lt;br /&gt;
* Current coverage:&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document outlines a thorough plan to enhance testing and code coverage for the questionnaire_helper files in Expertiza. With defined objectives, including developing detailed test plans and scenarios, the project aims to address current code coverage gaps. Conversely, the questionnaire_helper.rb file saw marginal improvements, primarily due to existing full coverage in the update_questionnaire_questions method. Moving forward, the project will focus on implementing the outlined test plans, ensuring comprehensive testing and reliability for critical functionality across both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
* Github Pull Request: [https://github.com/expertiza/expertiza/pull/2950 Pull Request]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163738</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163738"/>
		<updated>2025-04-08T02:32:40Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2440. Testing for questionnaire_helper.&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project involves writing test cases for the `questionnaire_helper` and `review_bids_helper` files in Expertiza, an open-source assignment/project management portal built on the Ruby on Rails framework. This platform facilitates collaborative learning and feedback among both instructors and students. Instructors can create and customize assignments, define topics for student sign-ups, and manage teams for various projects. Students, on the other hand, can sign up for topics, form teams, and participate in peer reviews to enhance each other's learning experiences. Our goal is to develop comprehensive test plans and increase code coverage for these helper files to ensure their reliability and effectiveness in the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Current Code Coverage ===&lt;br /&gt;
* Questionnaire_helper: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi (pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Dependency Injection Principle (DIP)&lt;br /&gt;
The QuestionnaireHelper methods accept objects like questionnaire or scored_question as parameters rather than instantiating them internally. This reflects the Dependency Injection Principle, promoting loose coupling. It also makes the methods easier to test and reuse, since dependencies are provided externally and can be mocked or substituted as needed.&lt;br /&gt;
&lt;br /&gt;
* Single Responsibility Principle (SRP)&lt;br /&gt;
Each method in the QuestionnaireHelper module demonstrates the Single Responsibility Principle by handling a specific, well-defined task. For instance, the adjust_advice_size method is solely focused on resizing the advice fields based on score ranges, while the questionnaire_factory method exclusively deals with instantiating questionnaire objects depending on their type. This separation of concerns enhances both the clarity and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP)&lt;br /&gt;
Although not immediately visible in limited code snippets, the design follows the Open/Closed Principle by being open to extension but closed to modification. For example, to support new questionnaire types, developers can extend the logic in questionnaire_factory without altering the existing structure, making the system more scalable and adaptable to future changes.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern&lt;br /&gt;
The questionnaire_factory method resembles the Factory Method Pattern by generating different types of questionnaire instances based on input parameters. This pattern enables the dynamic creation of objects without hard-coding their specific classes, improving flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
* Strategy Pattern&lt;br /&gt;
Another applicable pattern is the Strategy Pattern, especially relevant if the behavior of questionnaires (e.g., scoring, rendering, or validation) varies by type. If such behaviors are encapsulated in interchangeable classes and selected at runtime (possibly via the factory method), it aligns well with the Strategy Pattern. This promotes code reusability and simplifies the addition of new behavior types without impacting existing logic.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The adjust_advice_size method ensures that every ScoredQuestion has exactly one QuestionAdvice for each score in the range defined by its parent questionnaire. It removes advice entries outside the valid range and eliminates duplicates, while also creating missing entries for scores within range.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
* Create a mock or real Questionnaire instance with:&lt;br /&gt;
  min_question_score = 1&lt;br /&gt;
  max_question_score = 5&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Create a ScoredQuestion with:&lt;br /&gt;
  id assigned&lt;br /&gt;
  question_advices association&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Populate the QuestionAdvice table with:&lt;br /&gt;
  Advice entries within the valid range&lt;br /&gt;
  Advice entries outside the valid range&lt;br /&gt;
  Duplicate advice entries for the same score&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Stub or use an in-memory DB to test without affecting real data.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Context 1: question is not a ScoredQuestion&lt;br /&gt;
  Should perform no changes.&lt;br /&gt;
* Context 2: question is a ScoredQuestion, with:&lt;br /&gt;
  Valid advice range entries → should remain untouched.&lt;br /&gt;
  Advice with scores outside [min, max] → should be deleted.&lt;br /&gt;
  Duplicate advice entries → should be reduced to one.&lt;br /&gt;
  Missing advice entries within valid range → should be created.&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
* In Context 1, the method should exit early and make no database changes.&lt;br /&gt;
* In Context 2:&lt;br /&gt;
  Only one QuestionAdvice should exist for each score in [min, max].&lt;br /&gt;
  No QuestionAdvice should exist with scores outside [min, max].&lt;br /&gt;
  All newly created QuestionAdvice entries should have the correct score and question_id.&lt;br /&gt;
  The total number of QuestionAdvice entries for the question should equal (max - min + 1).&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The update_questionnaire_questions method updates existing Question records with new attribute values received from the request parameters. It ensures that only the changed attributes are updated and saved, thereby optimizing database writes.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a review_bid, and the number of participants (num_participants). Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Given a Valid Type: This context verifies the behavior when a valid questionnaire type is provided. It expects that calling questionnaire_factory with a valid type results in an instance of the specified questionnaire type (ReviewQuestionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when given a valid type' do&lt;br /&gt;
      it 'returns an instance of the specified questionnaire type' do&lt;br /&gt;
        questionnaire_type = 'ReviewQuestionnaire'&lt;br /&gt;
        expect(helper.questionnaire_factory(questionnaire_type)).to be_an_instance_of(ReviewQuestionnaire)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Given an Invalid Type: This context tests how the method handles an invalid questionnaire type. It expects that calling questionnaire_factory with an invalid type sets an error flash message indicating that the questionnaire type is undefined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when given an invalid type' do&lt;br /&gt;
      it 'sets an error flash message' do&lt;br /&gt;
        questionnaire_type = 'UnknownQuestionnaire'&lt;br /&gt;
        expect { helper.questionnaire_factory(questionnaire_type) }.to change { flash[:error] }.from(nil).to('Error: Undefined Questionnaire')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use expect and change statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ====&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
* Current coverage:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire helper spec coverage.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document outlines a thorough plan to enhance testing and code coverage for the questionnaire_helper files in Expertiza. With defined objectives, including developing detailed test plans and scenarios, the project aims to address current code coverage gaps. Conversely, the questionnaire_helper.rb file saw marginal improvements, primarily due to existing full coverage in the update_questionnaire_questions method. Moving forward, the project will focus on implementing the outlined test plans, ensuring comprehensive testing and reliability for critical functionality across both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
* Github Pull Request: [https://github.com/expertiza/expertiza/pull/2950 Pull Request]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163679</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163679"/>
		<updated>2025-04-08T02:13:18Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2440. Testing for questionnaire_helper.&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project involves writing test cases for the `questionnaire_helper` and `review_bids_helper` files in Expertiza, an open-source assignment/project management portal built on the Ruby on Rails framework. This platform facilitates collaborative learning and feedback among both instructors and students. Instructors can create and customize assignments, define topics for student sign-ups, and manage teams for various projects. Students, on the other hand, can sign up for topics, form teams, and participate in peer reviews to enhance each other's learning experiences. Our goal is to develop comprehensive test plans and increase code coverage for these helper files to ensure their reliability and effectiveness in the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Current Code Coverage ===&lt;br /&gt;
* Questionnaire_helper: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi(pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Dependency Injection Principle (DIP)&lt;br /&gt;
The QuestionnaireHelper methods accept objects like questionnaire or scored_question as parameters rather than instantiating them internally. This reflects the Dependency Injection Principle, promoting loose coupling. It also makes the methods easier to test and reuse, since dependencies are provided externally and can be mocked or substituted as needed.&lt;br /&gt;
&lt;br /&gt;
* Single Responsibility Principle (SRP)&lt;br /&gt;
Each method in the QuestionnaireHelper module demonstrates the Single Responsibility Principle by handling a specific, well-defined task. For instance, the adjust_advice_size method is solely focused on resizing the advice fields based on score ranges, while the questionnaire_factory method exclusively deals with instantiating questionnaire objects depending on their type. This separation of concerns enhances both the clarity and maintainability of the code.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP)&lt;br /&gt;
Although not immediately visible in limited code snippets, the design follows the Open/Closed Principle by being open to extension but closed to modification. For example, to support new questionnaire types, developers can extend the logic in questionnaire_factory without altering the existing structure, making the system more scalable and adaptable to future changes.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern&lt;br /&gt;
The questionnaire_factory method resembles the Factory Method Pattern by generating different types of questionnaire instances based on input parameters. This pattern enables the dynamic creation of objects without hard-coding their specific classes, improving flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
* Strategy Pattern&lt;br /&gt;
Another applicable pattern is the Strategy Pattern, especially relevant if the behavior of questionnaires (e.g., scoring, rendering, or validation) varies by type. If such behaviors are encapsulated in interchangeable classes and selected at runtime (possibly via the factory method), it aligns well with the Strategy Pattern. This promotes code reusability and simplifies the addition of new behavior types without impacting existing logic.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The .adjust_advice_size method is being described. This method likely adjusts the size of advice related to questions based on certain conditions.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a questionnaire, a scored_question, a non_scored_question, and a question_advice.&lt;br /&gt;
Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Question is a ScoredQuestion: This context tests the behavior when the question is a scored question. It sets up expectations related to the adjustment of advice size based on the questionnaire scores.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when question is a ScoredQuestion' do&lt;br /&gt;
      it 'adjusts advice size based on questionnaire scores' do&lt;br /&gt;
    allow(QuestionAdvice).to receive(:where).and_return([])&lt;br /&gt;
    allow(QuestionAdvice).to receive(:new).and_return(double('QuestionAdvice', save: true))&lt;br /&gt;
    allow(scored_question).to receive(:is_a?).with(ScoredQuestion).and_return(true)&lt;br /&gt;
    described_class.adjust_advice_size(questionnaire, scored_question)&lt;br /&gt;
    expect(QuestionAdvice).to have_received(:where).exactly(10).times&lt;br /&gt;
    expect(scored_question.question_advices.size).to eq(10)&lt;br /&gt;
  end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Question is Not a ScoredQuestion: This context tests the behavior when the question is not a scored question. It verifies that in this case, the advice size is not adjusted.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when question is not a ScoredQuestion' do&lt;br /&gt;
      it 'does not adjust advice size' do&lt;br /&gt;
        allow(QuestionAdvice).to receive(:where)&lt;br /&gt;
        allow(QuestionAdvice).to receive(:new)&lt;br /&gt;
        allow(scored_question).to receive(:is_a?).with(ScoredQuestion).and_return(false)&lt;br /&gt;
        described_class.adjust_advice_size(questionnaire, non_scored_question)&lt;br /&gt;
        expect(QuestionAdvice).not_to have_received(:where)&lt;br /&gt;
        expect(QuestionAdvice).not_to have_received(:new)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use allow and expect statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The .questionnaire_factory method is described. It seems to be a factory method responsible for creating instances of different questionnaire types based on the given type parameter.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a review_bid, and the number of participants (num_participants). Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Given a Valid Type: This context verifies the behavior when a valid questionnaire type is provided. It expects that calling questionnaire_factory with a valid type results in an instance of the specified questionnaire type (ReviewQuestionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when given a valid type' do&lt;br /&gt;
      it 'returns an instance of the specified questionnaire type' do&lt;br /&gt;
        questionnaire_type = 'ReviewQuestionnaire'&lt;br /&gt;
        expect(helper.questionnaire_factory(questionnaire_type)).to be_an_instance_of(ReviewQuestionnaire)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Given an Invalid Type: This context tests how the method handles an invalid questionnaire type. It expects that calling questionnaire_factory with an invalid type sets an error flash message indicating that the questionnaire type is undefined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when given an invalid type' do&lt;br /&gt;
      it 'sets an error flash message' do&lt;br /&gt;
        questionnaire_type = 'UnknownQuestionnaire'&lt;br /&gt;
        expect { helper.questionnaire_factory(questionnaire_type) }.to change { flash[:error] }.from(nil).to('Error: Undefined Questionnaire')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use expect and change statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ====&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
* Current coverage:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire helper spec coverage.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document outlines a thorough plan to enhance testing and code coverage for the questionnaire_helper files in Expertiza. With defined objectives, including developing detailed test plans and scenarios, the project aims to address current code coverage gaps. Conversely, the questionnaire_helper.rb file saw marginal improvements, primarily due to existing full coverage in the update_questionnaire_questions method. Moving forward, the project will focus on implementing the outlined test plans, ensuring comprehensive testing and reliability for critical functionality across both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
* Github Pull Request: [https://github.com/expertiza/expertiza/pull/2950 Pull Request]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163641</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163641"/>
		<updated>2025-04-08T01:58:16Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2025 E2440. Testing for questionnaire_helper.&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project involves writing test cases for the `questionnaire_helper` and `review_bids_helper` files in Expertiza, an open-source assignment/project management portal built on the Ruby on Rails framework. This platform facilitates collaborative learning and feedback among both instructors and students. Instructors can create and customize assignments, define topics for student sign-ups, and manage teams for various projects. Students, on the other hand, can sign up for topics, form teams, and participate in peer reviews to enhance each other's learning experiences. Our goal is to develop comprehensive test plans and increase code coverage for these helper files to ensure their reliability and effectiveness in the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Current Code Coverage ===&lt;br /&gt;
* Questionnaire_helper: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Aniruddha Rajenkar (aarajenkar@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi(pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
In Expertiza, the QuestionnaireHelper module plays a key role in managing questionnaires by providing methods to handle advice sizing, question updates, and questionnaire creation based on type. It also contains constants that assist in executing these tasks. These methods contribute to the smooth handling of questionnaire functionalities across the application. Below are the constants and methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Single Responsibility Principle (SRP):&lt;br /&gt;
Each method within the QuestionnaireHelper class appears to adhere to the SRP by focusing on a single task or responsibility. For example, the adjust_advice_size method is responsible for adjusting the size of advice based on questionnaire scores, while the questionnaire_factory method is responsible for creating instances of questionnaire types based on the given type parameter. This adherence ensures that each method has a clear and distinct purpose, promoting code maintainability and readability.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP):&lt;br /&gt;
While not explicitly evident in the provided snippets, the design allows for extension without modification, which aligns with the OCP. For instance, new types of questionnaires can be added without altering existing code by simply extending the questionnaire_factory method to accommodate the new types.&lt;br /&gt;
&lt;br /&gt;
* Dependency Injection Principle (DIP):&lt;br /&gt;
The methods in the QuestionnaireHelper class accept various objects (e.g., questionnaire, scored_question) as parameters, adhering to the principle of dependency injection. By accepting dependencies from external sources rather than creating them internally, these methods become more flexible and easily testable.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern:&lt;br /&gt;
The questionnaire_factory method can be seen as exhibiting characteristics of the factory method pattern. It dynamically creates instances of different questionnaire types based on the given type parameter, promoting flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The .adjust_advice_size method is being described. This method likely adjusts the size of advice related to questions based on certain conditions.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a questionnaire, a scored_question, a non_scored_question, and a question_advice.&lt;br /&gt;
Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Question is a ScoredQuestion: This context tests the behavior when the question is a scored question. It sets up expectations related to the adjustment of advice size based on the questionnaire scores.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when question is a ScoredQuestion' do&lt;br /&gt;
      it 'adjusts advice size based on questionnaire scores' do&lt;br /&gt;
    allow(QuestionAdvice).to receive(:where).and_return([])&lt;br /&gt;
    allow(QuestionAdvice).to receive(:new).and_return(double('QuestionAdvice', save: true))&lt;br /&gt;
    allow(scored_question).to receive(:is_a?).with(ScoredQuestion).and_return(true)&lt;br /&gt;
    described_class.adjust_advice_size(questionnaire, scored_question)&lt;br /&gt;
    expect(QuestionAdvice).to have_received(:where).exactly(10).times&lt;br /&gt;
    expect(scored_question.question_advices.size).to eq(10)&lt;br /&gt;
  end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Question is Not a ScoredQuestion: This context tests the behavior when the question is not a scored question. It verifies that in this case, the advice size is not adjusted.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when question is not a ScoredQuestion' do&lt;br /&gt;
      it 'does not adjust advice size' do&lt;br /&gt;
        allow(QuestionAdvice).to receive(:where)&lt;br /&gt;
        allow(QuestionAdvice).to receive(:new)&lt;br /&gt;
        allow(scored_question).to receive(:is_a?).with(ScoredQuestion).and_return(false)&lt;br /&gt;
        described_class.adjust_advice_size(questionnaire, non_scored_question)&lt;br /&gt;
        expect(QuestionAdvice).not_to have_received(:where)&lt;br /&gt;
        expect(QuestionAdvice).not_to have_received(:new)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use allow and expect statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The .questionnaire_factory method is described. It seems to be a factory method responsible for creating instances of different questionnaire types based on the given type parameter.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a review_bid, and the number of participants (num_participants). Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Given a Valid Type: This context verifies the behavior when a valid questionnaire type is provided. It expects that calling questionnaire_factory with a valid type results in an instance of the specified questionnaire type (ReviewQuestionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when given a valid type' do&lt;br /&gt;
      it 'returns an instance of the specified questionnaire type' do&lt;br /&gt;
        questionnaire_type = 'ReviewQuestionnaire'&lt;br /&gt;
        expect(helper.questionnaire_factory(questionnaire_type)).to be_an_instance_of(ReviewQuestionnaire)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Given an Invalid Type: This context tests how the method handles an invalid questionnaire type. It expects that calling questionnaire_factory with an invalid type sets an error flash message indicating that the questionnaire type is undefined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when given an invalid type' do&lt;br /&gt;
      it 'sets an error flash message' do&lt;br /&gt;
        questionnaire_type = 'UnknownQuestionnaire'&lt;br /&gt;
        expect { helper.questionnaire_factory(questionnaire_type) }.to change { flash[:error] }.from(nil).to('Error: Undefined Questionnaire')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use expect and change statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
We did not implement test cases for this method because it was already covered in last semester by previous team.&lt;br /&gt;
&lt;br /&gt;
==== Objective ====&lt;br /&gt;
Verify that the method get_intelligent_topic_row_review_bids correctly renders the topic row for the topics table in review_bids/show.html.erb. The #get_intelligent_topic_row_review_bids method is being described. This method likely generates HTML code for displaying topic rows based on certain conditions.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a selected_topic, the number of participants (num_participants), and a review_bid.&lt;br /&gt;
Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system. For example, selected_topic is set with a topic ID of 1 and is not waitlisted initially.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Selected Topics are Present: This context tests the behavior of the method when there are selected topics. It sets up a selected topic that is not waitlisted and expects the generated HTML to include a table row with a yellow background.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topics are present' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topic = instance_double('SelectedTopic')&lt;br /&gt;
        allow(selected_topic).to receive(:topic_id).and_return(1)&lt;br /&gt;
        allow(selected_topic).to receive(:is_waitlisted).and_return(false)&lt;br /&gt;
        selected_topics = [selected_topic]&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr bgcolor=&amp;quot;yellow&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Selected Topic is Waitlisted: This context tests the behavior when the selected topic is waitlisted. It sets up a selected topic that is waitlisted and expects the generated HTML to include a table row with a light gray background.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topic is waitlisted' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topic = instance_double('SelectedTopic')&lt;br /&gt;
        allow(selected_topic).to receive(:topic_id).and_return(1)&lt;br /&gt;
        allow(selected_topic).to receive(:is_waitlisted).and_return(true)&lt;br /&gt;
        selected_topics = [selected_topic]&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr bgcolor=&amp;quot;lightgray&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Selected Topics are Not Present: This context checks what happens when there are no selected topics. It mocks a method (get_topic_bg_color_review_bids) to return a specific background color and expects the generated HTML to include a table row with that background color.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topics are not present' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        allow(helper).to receive(:get_topic_bg_color_review_bids).and_return('rgb(255,255,255)')&lt;br /&gt;
        selected_topics = []&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr id=&amp;quot;topic_1&amp;quot; style=&amp;quot;background-color:rgb(255,255,255)&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Selected Topics are Nil: This context tests how the method handles cases where the selected topics parameter is nil. It expects the generated HTML to include a table row with a specific background color.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topics are nil' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topics = nil&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr id=&amp;quot;topic_1&amp;quot; style=&amp;quot;background-color:rgb(47,352,0)&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each context contains an it block with an expectation. These expectations use expect statements to verify that the HTML generated by the method meets certain criteria, such as containing specific table row elements with appropriate background colors.&lt;br /&gt;
&lt;br /&gt;
==== Objective ====&lt;br /&gt;
Verify that the method get_topic_bg_color_review_bids correctly calculates the background color for a topic in the review_bids/show.html.erb template. The #get_topic_bg_color_review_bids method is being described. This method likely determines the background color for a topic based on certain conditions.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a review_bid, and the number of participants (num_participants). Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Returns RGB Color Code: This test checks if the method returns an RGB color code for the topic background color. It sets up an expectation that the returned color code matches the pattern rgb(\d+,\d+,\d+), indicating it's in the correct format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when there are no review bids' do&lt;br /&gt;
      it 'returns default RGB color code' do&lt;br /&gt;
        allow(ReviewBid).to receive(:where).with(signuptopic_id: topic.id).and_return([])&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_topic_bg_color_review_bids(topic, num_participants)).to eq('rgb(47,352,0)')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When There Are No Review Bids: This context tests the behavior when there are no review bids associated with the topic. It sets up an expectation that the method returns a default RGB color code (rgb(47,352,0)), likely indicating a green color.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topic is waitlisted' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topic = instance_double('SelectedTopic')&lt;br /&gt;
        allow(selected_topic).to receive(:topic_id).and_return(1)&lt;br /&gt;
        allow(selected_topic).to receive(:is_waitlisted).and_return(true)&lt;br /&gt;
        selected_topics = [selected_topic]&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr bgcolor=&amp;quot;lightgray&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use expect statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
* Current coverage:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire helper spec coverage.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document outlines a thorough plan to enhance testing and code coverage for the questionnaire_helper files in Expertiza. With defined objectives, including developing detailed test plans and scenarios, the project aims to address current code coverage gaps. Conversely, the questionnaire_helper.rb file saw marginal improvements, primarily due to existing full coverage in the update_questionnaire_questions method. Moving forward, the project will focus on implementing the outlined test plans, ensuring comprehensive testing and reliability for critical functionality across both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163637</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163637"/>
		<updated>2025-04-08T01:54:35Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2024 E2440. Testing for questionnaire_helper, review_bids_helper&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project involves writing test cases for the `questionnaire_helper` and `review_bids_helper` files in Expertiza, an open-source assignment/project management portal built on the Ruby on Rails framework. This platform facilitates collaborative learning and feedback among both instructors and students. Instructors can create and customize assignments, define topics for student sign-ups, and manage teams for various projects. Students, on the other hand, can sign up for topics, form teams, and participate in peer reviews to enhance each other's learning experiences. Our goal is to develop comprehensive test plans and increase code coverage for these helper files to ensure their reliability and effectiveness in the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Current Code Coverage ===&lt;br /&gt;
* Questionnaire_helper: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Muhammet Mustafa Olmez (molmez@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Priya Gandhi(pgandhi4@ncsu.edu)&lt;br /&gt;
* Saisumanth Tallapragada (stallap@ncsu.edu)&lt;br /&gt;
* Ishani Rajput (irajput@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
The QuestionnaireHelper module contains several methods to assist with managing questionnaires in expertiza. QuestionnaireHelper provides methods for adjusting advice size, updating questionnaire questions, and creating questionnaire instances based on types. It also defines constants to facilitate these functionalities. These methods are likely used within the application to handle questionnaire-related tasks efficiently. Let's break down the class and its methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants serve as index references for different fields in a CSV row related to questionnaire data, such as the question text, type, parameters, and weight.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - A constant hash that maps string identifiers of questionnaire types to their respective Ruby class names.&lt;br /&gt;
   - Enables dynamic creation of questionnaire objects based on type strings.&lt;br /&gt;
   - Used by the questionnaire_factory method to instantiate the appropriate questionnaire class.&lt;br /&gt;
   - Helps avoid repetitive conditional logic by centralizing type-to-class associations.&lt;br /&gt;
   - Example mapping: 'ReviewQuestionnaire' =&amp;gt; ReviewQuestionnaire&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - Ensures that for each valid score in a ScoredQuestion, there exists exactly one QuestionAdvice. It removes extra or invalid advice entries and adds missing ones.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: An instance of a questionnaire that contains scoring boundaries (min_question_score and max_question_score)&lt;br /&gt;
     - `question`: An instance of ScoredQuestion for which advice needs to be validated and adjusted.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a ScoredQuestion.&lt;br /&gt;
     - Retrieves the min and max possible scores for the questionnaire.&lt;br /&gt;
     - Deletes any QuestionAdvice entries for this question that are outside the score bounds.&lt;br /&gt;
     - Iterates through all valid scores in the range [min, max]:&lt;br /&gt;
       - Adds a new QuestionAdvice if none exists for that score.&lt;br /&gt;
       - Deletes extra advice entries if more than one exists for the same score.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - Updates the attributes of questions in a questionnaire based on form parameters. It only updates attributes whose values have actually changed.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Returns early if params[:question] is nil.&lt;br /&gt;
     - Iterates through each question ID (k) and corresponding attributes (v) in params[:question].&lt;br /&gt;
     - Finds the Question object by ID.&lt;br /&gt;
     - For each attribute:&lt;br /&gt;
       - If the current value differs from the new value, updates the attribute. &lt;br /&gt;
     - Saves the updated question to the database.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - Creates a new instance of a questionnaire based on its type string using a predefined mapping.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: A String representing the name of the questionnaire type (e.g., &amp;quot;ReviewQuestionnaire&amp;quot;)&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Looks up the class constant from the QUESTIONNAIRE_MAP using the given type string.&lt;br /&gt;
     - If no match is found, sets a flash error (flash[:error]).&lt;br /&gt;
     - If a match is found, returns a new instance of the corresponding questionnaire class.&lt;br /&gt;
&lt;br /&gt;
== Objective : Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Single Responsibility Principle (SRP):&lt;br /&gt;
Each method within the QuestionnaireHelper class appears to adhere to the SRP by focusing on a single task or responsibility. For example, the adjust_advice_size method is responsible for adjusting the size of advice based on questionnaire scores, while the questionnaire_factory method is responsible for creating instances of questionnaire types based on the given type parameter. This adherence ensures that each method has a clear and distinct purpose, promoting code maintainability and readability.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP):&lt;br /&gt;
While not explicitly evident in the provided snippets, the design allows for extension without modification, which aligns with the OCP. For instance, new types of questionnaires can be added without altering existing code by simply extending the questionnaire_factory method to accommodate the new types.&lt;br /&gt;
&lt;br /&gt;
* Dependency Injection Principle (DIP):&lt;br /&gt;
The methods in the QuestionnaireHelper class accept various objects (e.g., questionnaire, scored_question) as parameters, adhering to the principle of dependency injection. By accepting dependencies from external sources rather than creating them internally, these methods become more flexible and easily testable.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern:&lt;br /&gt;
The questionnaire_factory method can be seen as exhibiting characteristics of the factory method pattern. It dynamically creates instances of different questionnaire types based on the given type parameter, promoting flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The .adjust_advice_size method is being described. This method likely adjusts the size of advice related to questions based on certain conditions.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a questionnaire, a scored_question, a non_scored_question, and a question_advice.&lt;br /&gt;
Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Question is a ScoredQuestion: This context tests the behavior when the question is a scored question. It sets up expectations related to the adjustment of advice size based on the questionnaire scores.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when question is a ScoredQuestion' do&lt;br /&gt;
      it 'adjusts advice size based on questionnaire scores' do&lt;br /&gt;
    allow(QuestionAdvice).to receive(:where).and_return([])&lt;br /&gt;
    allow(QuestionAdvice).to receive(:new).and_return(double('QuestionAdvice', save: true))&lt;br /&gt;
    allow(scored_question).to receive(:is_a?).with(ScoredQuestion).and_return(true)&lt;br /&gt;
    described_class.adjust_advice_size(questionnaire, scored_question)&lt;br /&gt;
    expect(QuestionAdvice).to have_received(:where).exactly(10).times&lt;br /&gt;
    expect(scored_question.question_advices.size).to eq(10)&lt;br /&gt;
  end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Question is Not a ScoredQuestion: This context tests the behavior when the question is not a scored question. It verifies that in this case, the advice size is not adjusted.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when question is not a ScoredQuestion' do&lt;br /&gt;
      it 'does not adjust advice size' do&lt;br /&gt;
        allow(QuestionAdvice).to receive(:where)&lt;br /&gt;
        allow(QuestionAdvice).to receive(:new)&lt;br /&gt;
        allow(scored_question).to receive(:is_a?).with(ScoredQuestion).and_return(false)&lt;br /&gt;
        described_class.adjust_advice_size(questionnaire, non_scored_question)&lt;br /&gt;
        expect(QuestionAdvice).not_to have_received(:where)&lt;br /&gt;
        expect(QuestionAdvice).not_to have_received(:new)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use allow and expect statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The .questionnaire_factory method is described. It seems to be a factory method responsible for creating instances of different questionnaire types based on the given type parameter.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a review_bid, and the number of participants (num_participants). Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Given a Valid Type: This context verifies the behavior when a valid questionnaire type is provided. It expects that calling questionnaire_factory with a valid type results in an instance of the specified questionnaire type (ReviewQuestionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when given a valid type' do&lt;br /&gt;
      it 'returns an instance of the specified questionnaire type' do&lt;br /&gt;
        questionnaire_type = 'ReviewQuestionnaire'&lt;br /&gt;
        expect(helper.questionnaire_factory(questionnaire_type)).to be_an_instance_of(ReviewQuestionnaire)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Given an Invalid Type: This context tests how the method handles an invalid questionnaire type. It expects that calling questionnaire_factory with an invalid type sets an error flash message indicating that the questionnaire type is undefined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when given an invalid type' do&lt;br /&gt;
      it 'sets an error flash message' do&lt;br /&gt;
        questionnaire_type = 'UnknownQuestionnaire'&lt;br /&gt;
        expect { helper.questionnaire_factory(questionnaire_type) }.to change { flash[:error] }.from(nil).to('Error: Undefined Questionnaire')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use expect and change statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
We did not implement test cases for this method because it was already covered in last semester by previous team.&lt;br /&gt;
&lt;br /&gt;
==== Objective ====&lt;br /&gt;
Verify that the method get_intelligent_topic_row_review_bids correctly renders the topic row for the topics table in review_bids/show.html.erb. The #get_intelligent_topic_row_review_bids method is being described. This method likely generates HTML code for displaying topic rows based on certain conditions.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a selected_topic, the number of participants (num_participants), and a review_bid.&lt;br /&gt;
Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system. For example, selected_topic is set with a topic ID of 1 and is not waitlisted initially.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Selected Topics are Present: This context tests the behavior of the method when there are selected topics. It sets up a selected topic that is not waitlisted and expects the generated HTML to include a table row with a yellow background.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topics are present' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topic = instance_double('SelectedTopic')&lt;br /&gt;
        allow(selected_topic).to receive(:topic_id).and_return(1)&lt;br /&gt;
        allow(selected_topic).to receive(:is_waitlisted).and_return(false)&lt;br /&gt;
        selected_topics = [selected_topic]&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr bgcolor=&amp;quot;yellow&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Selected Topic is Waitlisted: This context tests the behavior when the selected topic is waitlisted. It sets up a selected topic that is waitlisted and expects the generated HTML to include a table row with a light gray background.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topic is waitlisted' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topic = instance_double('SelectedTopic')&lt;br /&gt;
        allow(selected_topic).to receive(:topic_id).and_return(1)&lt;br /&gt;
        allow(selected_topic).to receive(:is_waitlisted).and_return(true)&lt;br /&gt;
        selected_topics = [selected_topic]&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr bgcolor=&amp;quot;lightgray&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Selected Topics are Not Present: This context checks what happens when there are no selected topics. It mocks a method (get_topic_bg_color_review_bids) to return a specific background color and expects the generated HTML to include a table row with that background color.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topics are not present' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        allow(helper).to receive(:get_topic_bg_color_review_bids).and_return('rgb(255,255,255)')&lt;br /&gt;
        selected_topics = []&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr id=&amp;quot;topic_1&amp;quot; style=&amp;quot;background-color:rgb(255,255,255)&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Selected Topics are Nil: This context tests how the method handles cases where the selected topics parameter is nil. It expects the generated HTML to include a table row with a specific background color.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topics are nil' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topics = nil&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr id=&amp;quot;topic_1&amp;quot; style=&amp;quot;background-color:rgb(47,352,0)&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each context contains an it block with an expectation. These expectations use expect statements to verify that the HTML generated by the method meets certain criteria, such as containing specific table row elements with appropriate background colors.&lt;br /&gt;
&lt;br /&gt;
==== Objective ====&lt;br /&gt;
Verify that the method get_topic_bg_color_review_bids correctly calculates the background color for a topic in the review_bids/show.html.erb template. The #get_topic_bg_color_review_bids method is being described. This method likely determines the background color for a topic based on certain conditions.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a review_bid, and the number of participants (num_participants). Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Returns RGB Color Code: This test checks if the method returns an RGB color code for the topic background color. It sets up an expectation that the returned color code matches the pattern rgb(\d+,\d+,\d+), indicating it's in the correct format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when there are no review bids' do&lt;br /&gt;
      it 'returns default RGB color code' do&lt;br /&gt;
        allow(ReviewBid).to receive(:where).with(signuptopic_id: topic.id).and_return([])&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_topic_bg_color_review_bids(topic, num_participants)).to eq('rgb(47,352,0)')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When There Are No Review Bids: This context tests the behavior when there are no review bids associated with the topic. It sets up an expectation that the method returns a default RGB color code (rgb(47,352,0)), likely indicating a green color.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topic is waitlisted' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topic = instance_double('SelectedTopic')&lt;br /&gt;
        allow(selected_topic).to receive(:topic_id).and_return(1)&lt;br /&gt;
        allow(selected_topic).to receive(:is_waitlisted).and_return(true)&lt;br /&gt;
        selected_topics = [selected_topic]&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr bgcolor=&amp;quot;lightgray&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use expect statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
* Current coverage:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire helper spec coverage.jpg]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document outlines a thorough plan to enhance testing and code coverage for the questionnaire_helper files in Expertiza. With defined objectives, including developing detailed test plans and scenarios, the project aims to address current code coverage gaps. Conversely, the questionnaire_helper.rb file saw marginal improvements, primarily due to existing full coverage in the update_questionnaire_questions method. Moving forward, the project will focus on implementing the outlined test plans, ensuring comprehensive testing and reliability for critical functionality across both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163574</id>
		<title>CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2529._Testing_for_the_Questionnaire_Helper_in_Expertiza&amp;diff=163574"/>
		<updated>2025-04-08T01:16:40Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: Created page with &amp;quot;This page describes the changes made for the Spring 2024 E2440. Testing for questionnaire_helper, review_bids_helper  == Project Overview ==  === Problem Statement === Our project involves writing test cases for the `questionnaire_helper` and `review_bids_helper` files in Expertiza, an open-source assignment/project management portal built on the Ruby on Rails framework. This platform facilitates collaborative learning and feedback among both instructors and students. In...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the changes made for the Spring 2024 E2440. Testing for questionnaire_helper, review_bids_helper&lt;br /&gt;
&lt;br /&gt;
== Project Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Problem Statement ===&lt;br /&gt;
Our project involves writing test cases for the `questionnaire_helper` and `review_bids_helper` files in Expertiza, an open-source assignment/project management portal built on the Ruby on Rails framework. This platform facilitates collaborative learning and feedback among both instructors and students. Instructors can create and customize assignments, define topics for student sign-ups, and manage teams for various projects. Students, on the other hand, can sign up for topics, form teams, and participate in peer reviews to enhance each other's learning experiences. Our goal is to develop comprehensive test plans and increase code coverage for these helper files to ensure their reliability and effectiveness in the Expertiza platform.&lt;br /&gt;
&lt;br /&gt;
=== Current Code Coverage ===&lt;br /&gt;
* Questionnaire_helper: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb &lt;br /&gt;
* Review_bids_helper: 17.65%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Freview_bids_helper.rb &lt;br /&gt;
&lt;br /&gt;
=== Objectives ===&lt;br /&gt;
&lt;br /&gt;
* Develop test plans/scenarios for questionnaire_helper.rb&lt;br /&gt;
* Develop test plans/scenarios for review_bids_helper.rb&lt;br /&gt;
* Improve code coverage for questionnaire_helper.rb&lt;br /&gt;
* Improve code coverage for review_bids_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Files Involved ===&lt;br /&gt;
&lt;br /&gt;
* Questionnaire_helper.rb: /app/helpers/questionnaire_helper.rb&lt;br /&gt;
* Review_bids_helper.rb: /app/helpers/review_bids_helper.rb&lt;br /&gt;
&lt;br /&gt;
=== Mentor ===&lt;br /&gt;
&lt;br /&gt;
* Muhammet Mustafa Olmez (molmez@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
=== Team Members ===&lt;br /&gt;
&lt;br /&gt;
* Neha Vijay Patil (npatil2@ncsu.edu)&lt;br /&gt;
* Prachit Mhalgi (psmhalgi@ncsu.edu)&lt;br /&gt;
* Sahil Santosh Sawant (ssawant2@ncsu.edu)&lt;br /&gt;
&lt;br /&gt;
== Class and Method Overview ==&lt;br /&gt;
&lt;br /&gt;
=== QuestionnaireHelper ===&lt;br /&gt;
&lt;br /&gt;
The QuestionnaireHelper module contains several methods to assist with managing questionnaires in expertiza. QuestionnaireHelper provides methods for adjusting advice size, updating questionnaire questions, and creating questionnaire instances based on types. It also defines constants to facilitate these functionalities. These methods are likely used within the application to handle questionnaire-related tasks efficiently. Let's break down the class and its methods:&lt;br /&gt;
&lt;br /&gt;
==== Constants ====&lt;br /&gt;
&lt;br /&gt;
CSV_QUESTION, CSV_TYPE, CSV_PARAM, CSV_WEIGHT&lt;br /&gt;
   - These constants define indices for specific columns in a CSV file.&lt;br /&gt;
&lt;br /&gt;
QUESTIONNAIRE_MAP&lt;br /&gt;
   - This constant is a hash that maps questionnaire types to their respective questionnaire classes.&lt;br /&gt;
   - It's used by the `questionnaire_factory` method to determine the appropriate class to instantiate.&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. adjust_advice_size(questionnaire, question)&lt;br /&gt;
   - This method adjusts the size of advice associated with a given question in a questionnaire.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `questionnaire`: The questionnaire object.&lt;br /&gt;
     - `question`: The question object whose advice size needs adjustment.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks if the question is a `ScoredQuestion`.&lt;br /&gt;
     - Deletes any existing advice for the question outside the score range.&lt;br /&gt;
     - Iterates over the score range and ensures each score has an associated advice.&lt;br /&gt;
     - Deletes any duplicate advice records.&lt;br /&gt;
   &lt;br /&gt;
2. update_questionnaire_questions&lt;br /&gt;
   - This method updates attributes of questionnaire questions based on form data, without modifying unchanged attributes.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Checks for presence of `params[:question]`.&lt;br /&gt;
     - Iterates through each question and its attributes in the parameters.&lt;br /&gt;
     - Compares each attribute's current value with the new value from the parameters and updates if changed.&lt;br /&gt;
     - Saves the question.&lt;br /&gt;
&lt;br /&gt;
3. questionnaire_factory(type)&lt;br /&gt;
   - This method acts as a factory to create an appropriate questionnaire object based on the type provided.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `type`: The type of questionnaire.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Retrieves the questionnaire class from `QUESTIONNAIRE_MAP` based on the provided type.&lt;br /&gt;
     - If the type is not found in the map, it sets an error flash message.&lt;br /&gt;
     - Otherwise, it initializes a new instance of the corresponding questionnaire class and returns it.&lt;br /&gt;
&lt;br /&gt;
=== ReviewBidsHelper ===&lt;br /&gt;
&lt;br /&gt;
This Ruby module, `ReviewBidsHelper` serves as a helper module for views related to reviewing bids in expertiza. `ReviewBidsHelper` provides helper methods for rendering topic rows and determining the background color for topics based on their bid status and the number of participants. These methods are likely used in the views associated with reviewing bids in the application. Let's break down the class and its methods:&lt;br /&gt;
&lt;br /&gt;
==== Methods ====&lt;br /&gt;
&lt;br /&gt;
1. get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)&lt;br /&gt;
   - This method seems to be responsible for generating HTML markup for a row in a table displaying topics for review bids.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `topic`: Represents a specific topic being reviewed.&lt;br /&gt;
     - `selected_topics`: An array of topics that have been selected.&lt;br /&gt;
     - `num_participants`: The number of participants involved in the review process.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Iterates through the `selected_topics`.&lt;br /&gt;
     - Depending on the conditions (whether the topic is selected and not waitlisted, or selected and waitlisted), it generates a specific row HTML.&lt;br /&gt;
     - Returns the generated row HTML as safe HTML.&lt;br /&gt;
&lt;br /&gt;
2. get_topic_bg_color_review_bids(topic, num_participants)&lt;br /&gt;
   - This method calculates the background color for a topic based on the number of participants and the number of bids for that topic.&lt;br /&gt;
   - Parameters:&lt;br /&gt;
     - `topic`: Represents the topic for which the background color is being determined.&lt;br /&gt;
     - `num_participants`: The total number of participants.&lt;br /&gt;
   - Functionality:&lt;br /&gt;
     - Calculates the number of bids for the given `topic`.&lt;br /&gt;
     - Determines the proportion of bids compared to the total number of participants and adjusts the color accordingly.&lt;br /&gt;
     - Returns a string representing the RGB value of the background color.&lt;br /&gt;
&lt;br /&gt;
== Objective 1: Develop code testing scenarios for questionnaire_helper ==&lt;br /&gt;
* Single Responsibility Principle (SRP):&lt;br /&gt;
Each method within the QuestionnaireHelper class appears to adhere to the SRP by focusing on a single task or responsibility. For example, the adjust_advice_size method is responsible for adjusting the size of advice based on questionnaire scores, while the questionnaire_factory method is responsible for creating instances of questionnaire types based on the given type parameter. This adherence ensures that each method has a clear and distinct purpose, promoting code maintainability and readability.&lt;br /&gt;
&lt;br /&gt;
* Open/Closed Principle (OCP):&lt;br /&gt;
While not explicitly evident in the provided snippets, the design allows for extension without modification, which aligns with the OCP. For instance, new types of questionnaires can be added without altering existing code by simply extending the questionnaire_factory method to accommodate the new types.&lt;br /&gt;
&lt;br /&gt;
* Dependency Injection Principle (DIP):&lt;br /&gt;
The methods in the QuestionnaireHelper class accept various objects (e.g., questionnaire, scored_question) as parameters, adhering to the principle of dependency injection. By accepting dependencies from external sources rather than creating them internally, these methods become more flexible and easily testable.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern:&lt;br /&gt;
The questionnaire_factory method can be seen as exhibiting characteristics of the factory method pattern. It dynamically creates instances of different questionnaire types based on the given type parameter, promoting flexibility and extensibility.&lt;br /&gt;
&lt;br /&gt;
After reviewing the QuestionnaireHelper class, we identified three methods in the class that require testing. These methods are as follows:&lt;br /&gt;
&lt;br /&gt;
* adjust_advice_size&lt;br /&gt;
* questionnaire_factory&lt;br /&gt;
* update_questionnaire_questions&lt;br /&gt;
&lt;br /&gt;
=== adjust_advice_size ===&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The .adjust_advice_size method is being described. This method likely adjusts the size of advice related to questions based on certain conditions.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a questionnaire, a scored_question, a non_scored_question, and a question_advice.&lt;br /&gt;
Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Question is a ScoredQuestion: This context tests the behavior when the question is a scored question. It sets up expectations related to the adjustment of advice size based on the questionnaire scores.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when question is a ScoredQuestion' do&lt;br /&gt;
      it 'adjusts advice size based on questionnaire scores' do&lt;br /&gt;
    allow(QuestionAdvice).to receive(:where).and_return([])&lt;br /&gt;
    allow(QuestionAdvice).to receive(:new).and_return(double('QuestionAdvice', save: true))&lt;br /&gt;
    allow(scored_question).to receive(:is_a?).with(ScoredQuestion).and_return(true)&lt;br /&gt;
    described_class.adjust_advice_size(questionnaire, scored_question)&lt;br /&gt;
    expect(QuestionAdvice).to have_received(:where).exactly(10).times&lt;br /&gt;
    expect(scored_question.question_advices.size).to eq(10)&lt;br /&gt;
  end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Question is Not a ScoredQuestion: This context tests the behavior when the question is not a scored question. It verifies that in this case, the advice size is not adjusted.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when question is not a ScoredQuestion' do&lt;br /&gt;
      it 'does not adjust advice size' do&lt;br /&gt;
        allow(QuestionAdvice).to receive(:where)&lt;br /&gt;
        allow(QuestionAdvice).to receive(:new)&lt;br /&gt;
        allow(scored_question).to receive(:is_a?).with(ScoredQuestion).and_return(false)&lt;br /&gt;
        described_class.adjust_advice_size(questionnaire, non_scored_question)&lt;br /&gt;
        expect(QuestionAdvice).not_to have_received(:where)&lt;br /&gt;
        expect(QuestionAdvice).not_to have_received(:new)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use allow and expect statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
=== questionnaire_factory ===&lt;br /&gt;
&lt;br /&gt;
==== Method Description ====&lt;br /&gt;
The .questionnaire_factory method is described. It seems to be a factory method responsible for creating instances of different questionnaire types based on the given type parameter.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a review_bid, and the number of participants (num_participants). Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Given a Valid Type: This context verifies the behavior when a valid questionnaire type is provided. It expects that calling questionnaire_factory with a valid type results in an instance of the specified questionnaire type (ReviewQuestionnaire).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when given a valid type' do&lt;br /&gt;
      it 'returns an instance of the specified questionnaire type' do&lt;br /&gt;
        questionnaire_type = 'ReviewQuestionnaire'&lt;br /&gt;
        expect(helper.questionnaire_factory(questionnaire_type)).to be_an_instance_of(ReviewQuestionnaire)&lt;br /&gt;
      end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Given an Invalid Type: This context tests how the method handles an invalid questionnaire type. It expects that calling questionnaire_factory with an invalid type sets an error flash message indicating that the questionnaire type is undefined.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when given an invalid type' do&lt;br /&gt;
      it 'sets an error flash message' do&lt;br /&gt;
        questionnaire_type = 'UnknownQuestionnaire'&lt;br /&gt;
        expect { helper.questionnaire_factory(questionnaire_type) }.to change { flash[:error] }.from(nil).to('Error: Undefined Questionnaire')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use expect and change statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
=== update_questionnaire_questions ===&lt;br /&gt;
We did not implement test cases for this method because it was already covered in last semester by previous team.&lt;br /&gt;
&lt;br /&gt;
== Objective 2: Develop code testing scenarios for review_bids_helper ==&lt;br /&gt;
* Single Responsibility Principle (SRP):&lt;br /&gt;
Each method within the ReviewBidsHelper class seems to adhere to the SRP. For example, get_intelligent_topic_row_review_bids is responsible for generating HTML code for topic rows, while get_topic_bg_color_review_bids determines the background color for a topic. This adherence ensures that each method has a clear and distinct purpose, enhancing maintainability and readability.&lt;br /&gt;
&lt;br /&gt;
* Factory Method Pattern:&lt;br /&gt;
Although not explicitly labeled as a factory method, get_intelligent_topic_row_review_bids can be interpreted as following a similar pattern. It dynamically generates HTML code based on different scenarios, akin to a factory producing instances of objects. This promotes flexibility and extensibility in generating HTML representations of topics.&lt;br /&gt;
&lt;br /&gt;
After reviewing the ReviewBidsHelper module, we identified two methods that require testing:&lt;br /&gt;
&lt;br /&gt;
=== get_intelligent_topic_row_review_bids ===&lt;br /&gt;
==== Objective ====&lt;br /&gt;
Verify that the method get_intelligent_topic_row_review_bids correctly renders the topic row for the topics table in review_bids/show.html.erb. The #get_intelligent_topic_row_review_bids method is being described. This method likely generates HTML code for displaying topic rows based on certain conditions.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a selected_topic, the number of participants (num_participants), and a review_bid.&lt;br /&gt;
Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system. For example, selected_topic is set with a topic ID of 1 and is not waitlisted initially.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* When Selected Topics are Present: This context tests the behavior of the method when there are selected topics. It sets up a selected topic that is not waitlisted and expects the generated HTML to include a table row with a yellow background.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topics are present' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topic = instance_double('SelectedTopic')&lt;br /&gt;
        allow(selected_topic).to receive(:topic_id).and_return(1)&lt;br /&gt;
        allow(selected_topic).to receive(:is_waitlisted).and_return(false)&lt;br /&gt;
        selected_topics = [selected_topic]&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr bgcolor=&amp;quot;yellow&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Selected Topic is Waitlisted: This context tests the behavior when the selected topic is waitlisted. It sets up a selected topic that is waitlisted and expects the generated HTML to include a table row with a light gray background.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topic is waitlisted' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topic = instance_double('SelectedTopic')&lt;br /&gt;
        allow(selected_topic).to receive(:topic_id).and_return(1)&lt;br /&gt;
        allow(selected_topic).to receive(:is_waitlisted).and_return(true)&lt;br /&gt;
        selected_topics = [selected_topic]&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr bgcolor=&amp;quot;lightgray&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Selected Topics are Not Present: This context checks what happens when there are no selected topics. It mocks a method (get_topic_bg_color_review_bids) to return a specific background color and expects the generated HTML to include a table row with that background color.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topics are not present' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        allow(helper).to receive(:get_topic_bg_color_review_bids).and_return('rgb(255,255,255)')&lt;br /&gt;
        selected_topics = []&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr id=&amp;quot;topic_1&amp;quot; style=&amp;quot;background-color:rgb(255,255,255)&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When Selected Topics are Nil: This context tests how the method handles cases where the selected topics parameter is nil. It expects the generated HTML to include a table row with a specific background color.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topics are nil' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topics = nil&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr id=&amp;quot;topic_1&amp;quot; style=&amp;quot;background-color:rgb(47,352,0)&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each context contains an it block with an expectation. These expectations use expect statements to verify that the HTML generated by the method meets certain criteria, such as containing specific table row elements with appropriate background colors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== get_topic_bg_color_review_bids ===&lt;br /&gt;
&lt;br /&gt;
==== Objective ====&lt;br /&gt;
Verify that the method get_topic_bg_color_review_bids correctly calculates the background color for a topic in the review_bids/show.html.erb template. The #get_topic_bg_color_review_bids method is being described. This method likely determines the background color for a topic based on certain conditions.&lt;br /&gt;
&lt;br /&gt;
==== Test Setup ==== &lt;br /&gt;
Mock objects are set up using let statements. These include a topic, a review_bid, and the number of participants (num_participants). Each of these mock objects is prepared with predefined attributes that mimic the behavior of actual objects in the system.&lt;br /&gt;
&lt;br /&gt;
==== Test Contexts ====&lt;br /&gt;
&lt;br /&gt;
* Returns RGB Color Code: This test checks if the method returns an RGB color code for the topic background color. It sets up an expectation that the returned color code matches the pattern rgb(\d+,\d+,\d+), indicating it's in the correct format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 context 'when there are no review bids' do&lt;br /&gt;
      it 'returns default RGB color code' do&lt;br /&gt;
        allow(ReviewBid).to receive(:where).with(signuptopic_id: topic.id).and_return([])&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_topic_bg_color_review_bids(topic, num_participants)).to eq('rgb(47,352,0)')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* When There Are No Review Bids: This context tests the behavior when there are no review bids associated with the topic. It sets up an expectation that the method returns a default RGB color code (rgb(47,352,0)), likely indicating a green color.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
context 'when selected topic is waitlisted' do&lt;br /&gt;
      it 'returns HTML code for topic row with appropriate background color' do&lt;br /&gt;
        selected_topic = instance_double('SelectedTopic')&lt;br /&gt;
        allow(selected_topic).to receive(:topic_id).and_return(1)&lt;br /&gt;
        allow(selected_topic).to receive(:is_waitlisted).and_return(true)&lt;br /&gt;
        selected_topics = [selected_topic]&lt;br /&gt;
&lt;br /&gt;
        expect(helper.get_intelligent_topic_row_review_bids(topic, selected_topics, num_participants)).to include('&amp;lt;tr bgcolor=&amp;quot;lightgray&amp;quot;&amp;gt;')&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Expectations ====&lt;br /&gt;
Each test contains an it block with an expectation. These expectations use expect statements to verify the behavior of the method under different conditions.&lt;br /&gt;
&lt;br /&gt;
== Coverage Results ==&lt;br /&gt;
=== Questionnaire_helper ===&lt;br /&gt;
* Previous coverage: 66%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Fquestionnaire_helper.rb&lt;br /&gt;
* Current coverage:&lt;br /&gt;
&lt;br /&gt;
[[File:Questionnaire helper spec coverage.jpg]]&lt;br /&gt;
&lt;br /&gt;
=== Review bids helper ===&lt;br /&gt;
* Previous coverage: 17.65%: https://coveralls.io/builds/66490075/source?filename=app%2Fhelpers%2Freview_bids_helper.rb&lt;br /&gt;
* Current coverage: &lt;br /&gt;
&lt;br /&gt;
[[File:Review bid helper spec coverage.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
This document outlines a thorough plan to enhance testing and code coverage for the questionnaire_helper and review_bids_helper files in Expertiza. With defined objectives, including developing detailed test plans and scenarios, the project aims to address current code coverage gaps. Notably, significant improvements were achieved in the review_bids_helper.rb file, with comprehensive test plans substantially increasing code coverage. Conversely, the questionnaire_helper.rb file saw marginal improvements, primarily due to existing full coverage in the update_questionnaire_questions method. Moving forward, the project will focus on implementing the outlined test plans, ensuring comprehensive testing and reliability for critical functionality across both helper files.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Link to Expertiza repository: [https://github.com/expertiza/expertiza here]&lt;br /&gt;
&lt;br /&gt;
* Link to Testing video: [https://youtu.be/jDfmPUgDDXA]&lt;br /&gt;
&lt;br /&gt;
* Link to pull request : [https://github.com/expertiza/expertiza/pull/2799 here]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. Expertiza on GitHub (https://github.com/expertiza/expertiza) &amp;lt;br&amp;gt;&lt;br /&gt;
2. The live Expertiza website (http://expertiza.ncsu.edu/) &amp;lt;br&amp;gt;&lt;br /&gt;
3. Pluggable reputation systems for peer review: A web-service approach (https://doi.org/10.1109/FIE.2015.7344292)&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025&amp;diff=163573</id>
		<title>CSC/ECE 517 Spring 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025&amp;diff=163573"/>
		<updated>2025-04-08T01:16:08Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: /* Final Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2025 - E2503. Refactor the Team hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2504. Mentor-meeting management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2508. Reimplement bidding-algorithm web service]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2509. Reimplement feedback_response_map.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2519. Implement view for results of bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2522. Enhancing UI Consistency in Expertiza 1]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2520. Reimplement heatgrid UI for reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2517. Reimplement internationalization (frontend + backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2523: Enhancing UI Consistency in Expertiza 2]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2515:  Reimplement student_teams_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2501:  Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2502:  Refactor review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2512. Reimplement responses controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2510. Reimplement grades_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2514. Reimplement student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2518. Reimplement password resets (frontend + backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2516. Reimplement teams_users_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2511. Reimplement participants_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2521. UI for View submissions/assign grades (except heatgrid)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2513. Reimplement sign_up_topic.rb as project_topic.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2506. Implement testing for new Bookmarks Controller]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Final Projects ==&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2509 Refactoring and Enhancing the Feedback Response Map Controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2539 Reimplement Student Task View (Frontend + Backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2521 UI for View submissions/assign grades (except heatgrid)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2524 Reimplement student review controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2525 Reimplement review_mapping_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2526 Reimplement Teams and Participant hierarchies]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2530 Reimplement Grades Controller (Frontend + Backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2538 Reimplementing Questionnaire Page in Expertiza]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2534 UI for Assign Reviewers]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2540 Integration of Assignment participant Frontend with participant controller Backend]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2532. Reimplement Missing ResponseMap Subclasses]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2542. Refactor review_bids_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2533. ​​Reimplement the Team hierarchy]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2531 Refactor participants_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2514. Reimplement student_quizzes_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2516. Reimplement teams_users_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2535 Reimplement User Profile Management (Frontend + Backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2536. Improve assessment360 controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2527. Mentor-meeting management: assignments with topics]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2529. Testing for the Questionnaire Helper in Expertiza]]&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162398</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162398"/>
		<updated>2025-03-24T21:40:54Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
===Proposed System===&lt;br /&gt;
The primary objective of this project is to modify the Submission Record Controller so that submission records become visible to students. Previously, only instructors had access to these records. The key deliverables include:&lt;br /&gt;
&lt;br /&gt;
1. Updating the access control logic to grant students permission to view their own submission records.&lt;br /&gt;
&lt;br /&gt;
2. Ensuring students cannot access other teams’ submission records.&lt;br /&gt;
&lt;br /&gt;
3. Modifying the UI to present submission history in an intuitive manner.&lt;br /&gt;
&lt;br /&gt;
4. Updating API routes and database queries to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
5. Writing and executing test cases to validate the changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Files Involved==&lt;br /&gt;
&lt;br /&gt;
*app/controllers/submission_records_controller.rb&lt;br /&gt;
*app/models/submission_record.rb&lt;br /&gt;
*app/views/student_task/list.html.erb&lt;br /&gt;
*app/views/submission_records/index.html.erb&lt;br /&gt;
&lt;br /&gt;
==Database Tables Involved==&lt;br /&gt;
&lt;br /&gt;
*submission_records&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
1. Identify the Existing Access Control Mechanism:&lt;br /&gt;
We examined the existing authorization logic that restricted students from viewing their own submission records.&lt;br /&gt;
Access permissions were defined at the controller level, requiring updates to include student roles.&lt;br /&gt;
&lt;br /&gt;
2.Modify the Submission Record Controller:&lt;br /&gt;
We modified the controller to allow students to retrieve their own submission records while ensuring security constraints.&lt;br /&gt;
&lt;br /&gt;
Role-based conditions were implemented to prevent unauthorized access.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-controller.png|400px]]&lt;br /&gt;
&lt;br /&gt;
3.Update Submission-Records View for Students:&lt;br /&gt;
A new student-friendly interface was added to display submission history. &lt;br /&gt;
&lt;br /&gt;
The UI was updated to ensure that students could only access records linked to their own submissions.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-views.png|400px]]&lt;br /&gt;
&lt;br /&gt;
4.Create a New View for Submission Records:&lt;br /&gt;
A separate view was introduced to present submission records in a structured format.&lt;br /&gt;
&lt;br /&gt;
This view mirrors the instructor’s interface but with restricted data access.&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Submission History&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% if @submission_records.any? %&amp;gt;&lt;br /&gt;
  &amp;lt;table class=&amp;quot;table table-striped&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;thead&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Submission ID&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Submitted By&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Submission Time&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;File&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Comments&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;/thead&amp;gt;&lt;br /&gt;
    &amp;lt;tbody&amp;gt;&lt;br /&gt;
      &amp;lt;% @submission_records.each do |record| %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.submitter.try(:name) || &amp;quot;Unknown&amp;quot; %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.created_at.strftime(&amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;) %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&lt;br /&gt;
            &amp;lt;% if record.file_url.present? %&amp;gt;&lt;br /&gt;
              &amp;lt;%= link_to &amp;quot;View File&amp;quot;, record.file_url, target: &amp;quot;_blank&amp;quot; %&amp;gt;&lt;br /&gt;
            &amp;lt;% else %&amp;gt;&lt;br /&gt;
              No file uploaded&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.comments.presence || &amp;quot;No comments&amp;quot; %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/tbody&amp;gt;&lt;br /&gt;
  &amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;% else %&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;No submission records found for this team.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to &amp;quot;Back to Assignments&amp;quot;, assignments_path, class: &amp;quot;btn btn-primary&amp;quot; %&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5.Update API Routes in config/routes.rb:&lt;br /&gt;
New API endpoints were configured to fetch relevant submission data for students. The changes ensured compatibility with the existing API architecture.&lt;br /&gt;
&lt;br /&gt;
6.Perform Testing Using RSpec:&lt;br /&gt;
We wrote unit and integration tests to verify that the new functionality worked as expected. These tests ensured that students could only access their own submission records.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/delaneydow/reimplementation-back-end GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ The Live Expertiza Website]&lt;br /&gt;
&lt;br /&gt;
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Project Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://relishapp.com/rspec RSpec Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/reimplementation-back-end Reimplementation Backend Repository]&lt;br /&gt;
&lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1797_Timestamps_for_students_submission Referred Wiki Page]&lt;br /&gt;
&lt;br /&gt;
Clean Code: A Handbook of Agile Software Craftsmanship – Robert C. Martin&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
Priya Gandhi, Saisumanth Tallapragada, Delaney Dow&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
Anirudha Rajenkar, Ed Grehringer&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162397</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162397"/>
		<updated>2025-03-24T21:40:32Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
===Proposed System===&lt;br /&gt;
The primary objective of this project is to modify the Submission Record Controller so that submission records become visible to students. Previously, only instructors had access to these records. The key deliverables include:&lt;br /&gt;
&lt;br /&gt;
1. Updating the access control logic to grant students permission to view their own submission records.&lt;br /&gt;
&lt;br /&gt;
2. Ensuring students cannot access other teams’ submission records.&lt;br /&gt;
&lt;br /&gt;
3. Modifying the UI to present submission history in an intuitive manner.&lt;br /&gt;
&lt;br /&gt;
4. Updating API routes and database queries to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
5. Writing and executing test cases to validate the changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Files Involved==&lt;br /&gt;
&lt;br /&gt;
*app/controllers/submission_records_controller.rb&lt;br /&gt;
*app/models/submission_record.rb&lt;br /&gt;
*app/views/student_task/list.html.erb&lt;br /&gt;
*app/views/submission_records/index.html.erb&lt;br /&gt;
&lt;br /&gt;
==Database Tables Involved==&lt;br /&gt;
&lt;br /&gt;
*submission_records&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
1. Identify the Existing Access Control Mechanism:&lt;br /&gt;
We examined the existing authorization logic that restricted students from viewing their own submission records.&lt;br /&gt;
Access permissions were defined at the controller level, requiring updates to include student roles.&lt;br /&gt;
&lt;br /&gt;
2.Modify the Submission Record Controller:&lt;br /&gt;
We modified the controller to allow students to retrieve their own submission records while ensuring security constraints.&lt;br /&gt;
&lt;br /&gt;
Role-based conditions were implemented to prevent unauthorized access.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-controller.png|400px]]&lt;br /&gt;
&lt;br /&gt;
3.Update Submission-Records View for Students:&lt;br /&gt;
A new student-friendly interface was added to display submission history. &lt;br /&gt;
&lt;br /&gt;
The UI was updated to ensure that students could only access records linked to their own submissions.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-views.png|400px]]&lt;br /&gt;
&lt;br /&gt;
4.Create a New View for Submission Records:&lt;br /&gt;
A separate view was introduced to present submission records in a structured format.&lt;br /&gt;
&lt;br /&gt;
This view mirrors the instructor’s interface but with restricted data access.&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Submission History&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% if @submission_records.any? %&amp;gt;&lt;br /&gt;
  &amp;lt;table class=&amp;quot;table table-striped&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;thead&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Submission ID&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Submitted By&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Submission Time&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;File&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Comments&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;/thead&amp;gt;&lt;br /&gt;
    &amp;lt;tbody&amp;gt;&lt;br /&gt;
      &amp;lt;% @submission_records.each do |record| %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.submitter.try(:name) || &amp;quot;Unknown&amp;quot; %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.created_at.strftime(&amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;) %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&lt;br /&gt;
            &amp;lt;% if record.file_url.present? %&amp;gt;&lt;br /&gt;
              &amp;lt;%= link_to &amp;quot;View File&amp;quot;, record.file_url, target: &amp;quot;_blank&amp;quot; %&amp;gt;&lt;br /&gt;
            &amp;lt;% else %&amp;gt;&lt;br /&gt;
              No file uploaded&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.comments.presence || &amp;quot;No comments&amp;quot; %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/tbody&amp;gt;&lt;br /&gt;
  &amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;% else %&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;No submission records found for this team.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to &amp;quot;Back to Assignments&amp;quot;, assignments_path, class: &amp;quot;btn btn-primary&amp;quot; %&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5.Update API Routes in config/routes.rb:&lt;br /&gt;
New API endpoints were configured to fetch relevant submission data for students. The changes ensured compatibility with the existing API architecture.&lt;br /&gt;
&lt;br /&gt;
6.Perform Testing Using RSpec:&lt;br /&gt;
We wrote unit and integration tests to verify that the new functionality worked as expected. These tests ensured that students could only access their own submission records.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/delaneydow/reimplementation-back-end GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ The Live Expertiza Website]&lt;br /&gt;
&lt;br /&gt;
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Project Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://relishapp.com/rspec RSpec Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/reimplementation-back-end Reimplementation Backend Repository]&lt;br /&gt;
&lt;br /&gt;
[https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2017/E1797_Timestamps_for_students_submission Referred Wiki Page]&lt;br /&gt;
Clean Code: A Handbook of Agile Software Craftsmanship – Robert C. Martin&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
Priya Gandhi, Saisumanth Tallapragada, Delaney Dow&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
Anirudha Rajenkar, Ed Grehringer&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162380</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162380"/>
		<updated>2025-03-24T21:20:50Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
===Proposed System===&lt;br /&gt;
The primary objective of this project is to modify the Submission Record Controller so that submission records become visible to students. Previously, only instructors had access to these records. The key deliverables include:&lt;br /&gt;
&lt;br /&gt;
1. Updating the access control logic to grant students permission to view their own submission records.&lt;br /&gt;
&lt;br /&gt;
2. Ensuring students cannot access other teams’ submission records.&lt;br /&gt;
&lt;br /&gt;
3. Modifying the UI to present submission history in an intuitive manner.&lt;br /&gt;
&lt;br /&gt;
4. Updating API routes and database queries to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
5. Writing and executing test cases to validate the changes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Files Involved==&lt;br /&gt;
&lt;br /&gt;
*app/controllers/submission_records_controller.rb&lt;br /&gt;
*app/models/submission_record.rb&lt;br /&gt;
*app/views/student_task/list.html.erb&lt;br /&gt;
*app/views/submission_records/index.html.erb&lt;br /&gt;
&lt;br /&gt;
==Database Tables Involved==&lt;br /&gt;
&lt;br /&gt;
*submission_records&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
1. Identify the Existing Access Control Mechanism:&lt;br /&gt;
We examined the existing authorization logic that restricted students from viewing their own submission records.&lt;br /&gt;
Access permissions were defined at the controller level, requiring updates to include student roles.&lt;br /&gt;
&lt;br /&gt;
2.Modify the Submission Record Controller:&lt;br /&gt;
We modified the controller to allow students to retrieve their own submission records while ensuring security constraints.&lt;br /&gt;
&lt;br /&gt;
Role-based conditions were implemented to prevent unauthorized access.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-controller.png|400px]]&lt;br /&gt;
&lt;br /&gt;
3.Update Submission-Records View for Students:&lt;br /&gt;
A new student-friendly interface was added to display submission history. &lt;br /&gt;
&lt;br /&gt;
The UI was updated to ensure that students could only access records linked to their own submissions.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-views.png|400px]]&lt;br /&gt;
&lt;br /&gt;
4.Create a New View for Submission Records:&lt;br /&gt;
A separate view was introduced to present submission records in a structured format.&lt;br /&gt;
&lt;br /&gt;
This view mirrors the instructor’s interface but with restricted data access.&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;h1&amp;gt;Submission History&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;% if @submission_records.any? %&amp;gt;&lt;br /&gt;
  &amp;lt;table class=&amp;quot;table table-striped&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;thead&amp;gt;&lt;br /&gt;
      &amp;lt;tr&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Submission ID&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Submitted By&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Submission Time&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;File&amp;lt;/th&amp;gt;&lt;br /&gt;
        &amp;lt;th&amp;gt;Comments&amp;lt;/th&amp;gt;&lt;br /&gt;
      &amp;lt;/tr&amp;gt;&lt;br /&gt;
    &amp;lt;/thead&amp;gt;&lt;br /&gt;
    &amp;lt;tbody&amp;gt;&lt;br /&gt;
      &amp;lt;% @submission_records.each do |record| %&amp;gt;&lt;br /&gt;
        &amp;lt;tr&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.id %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.submitter.try(:name) || &amp;quot;Unknown&amp;quot; %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.created_at.strftime(&amp;quot;%Y-%m-%d %H:%M:%S&amp;quot;) %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&lt;br /&gt;
            &amp;lt;% if record.file_url.present? %&amp;gt;&lt;br /&gt;
              &amp;lt;%= link_to &amp;quot;View File&amp;quot;, record.file_url, target: &amp;quot;_blank&amp;quot; %&amp;gt;&lt;br /&gt;
            &amp;lt;% else %&amp;gt;&lt;br /&gt;
              No file uploaded&lt;br /&gt;
            &amp;lt;% end %&amp;gt;&lt;br /&gt;
          &amp;lt;/td&amp;gt;&lt;br /&gt;
          &amp;lt;td&amp;gt;&amp;lt;%= record.comments.presence || &amp;quot;No comments&amp;quot; %&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
        &amp;lt;/tr&amp;gt;&lt;br /&gt;
      &amp;lt;% end %&amp;gt;&lt;br /&gt;
    &amp;lt;/tbody&amp;gt;&lt;br /&gt;
  &amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;% else %&amp;gt;&lt;br /&gt;
  &amp;lt;p&amp;gt;No submission records found for this team.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;% end %&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;%= link_to &amp;quot;Back to Assignments&amp;quot;, assignments_path, class: &amp;quot;btn btn-primary&amp;quot; %&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
5.Update API Routes in config/routes.rb:&lt;br /&gt;
New API endpoints were configured to fetch relevant submission data for students. The changes ensured compatibility with the existing API architecture.&lt;br /&gt;
&lt;br /&gt;
6.Perform Testing Using RSpec:&lt;br /&gt;
We wrote unit and integration tests to verify that the new functionality worked as expected. These tests ensured that students could only access their own submission records.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/delaneydow/reimplementation-back-end GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ The Live Expertiza Website]&lt;br /&gt;
&lt;br /&gt;
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Project Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://relishapp.com/rspec RSpec Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/reimplementation-back-end Reimplementation Backend Repository]&lt;br /&gt;
&lt;br /&gt;
Clean Code: A Handbook of Agile Software Craftsmanship – Robert C. Martin&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
Priya Gandhi, Saisumanth Tallapragada, Delaney Dow&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
Anirudha Rajenkar, Ed Grehringer&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162375</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162375"/>
		<updated>2025-03-24T21:08:23Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Proposed System===&lt;br /&gt;
The primary objective of this project is to modify the Submission Record Controller so that submission records become visible to students. Previously, only instructors had access to these records. The key deliverables include:&lt;br /&gt;
&lt;br /&gt;
1. Updating the access control logic to grant students permission to view their own submission records.&lt;br /&gt;
&lt;br /&gt;
2. Ensuring students cannot access other teams’ submission records.&lt;br /&gt;
&lt;br /&gt;
3. Modifying the UI to present submission history in an intuitive manner.&lt;br /&gt;
&lt;br /&gt;
4. Updating API routes and database queries to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
5. Writing and executing test cases to validate the changes.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
&lt;br /&gt;
==Files Involved==&lt;br /&gt;
&lt;br /&gt;
*app/controllers/submission_records_controller.rb&lt;br /&gt;
*app/models/submission_record.rb&lt;br /&gt;
*app/views/student_task/list.html.erb&lt;br /&gt;
*app/views/submission_records/index.html.erb&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
1. Identify the Existing Access Control Mechanism:&lt;br /&gt;
We examined the existing authorization logic that restricted students from viewing their own submission records.&lt;br /&gt;
Access permissions were defined at the controller level, requiring updates to include student roles.&lt;br /&gt;
&lt;br /&gt;
2.Modify the Submission Record Controller:&lt;br /&gt;
We modified the controller to allow students to retrieve their own submission records while ensuring security constraints.&lt;br /&gt;
&lt;br /&gt;
Role-based conditions were implemented to prevent unauthorized access.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-controller.png|400px]]&lt;br /&gt;
&lt;br /&gt;
3.Update Submission-Records View for Students:&lt;br /&gt;
A new student-friendly interface was added to display submission history. &lt;br /&gt;
&lt;br /&gt;
The UI was updated to ensure that students could only access records linked to their own submissions.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-views.png|400px]]&lt;br /&gt;
&lt;br /&gt;
4.Create a New View for Submission Records:&lt;br /&gt;
A separate view was introduced to present submission records in a structured format.&lt;br /&gt;
&lt;br /&gt;
This view mirrors the instructor’s interface but with restricted data access.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-students-views.png|400px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5.Update API Routes in config/routes.rb:&lt;br /&gt;
New API endpoints were configured to fetch relevant submission data for students. The changes ensured compatibility with the existing API architecture.&lt;br /&gt;
&lt;br /&gt;
6.Perform Testing Using RSpec:&lt;br /&gt;
We wrote unit and integration tests to verify that the new functionality worked as expected. These tests ensured that students could only access their own submission records.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/WintersLt/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ The Live Expertiza Website]&lt;br /&gt;
&lt;br /&gt;
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Project Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://relishapp.com/rspec RSpec Documentation]&lt;br /&gt;
&lt;br /&gt;
Clean Code: A Handbook of Agile Software Craftsmanship – Robert C. Martin&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
Priya Gandhi, Saisumanth Tallapragada, Delaney Dow&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
Anirudha Rajenkar, Ed Grehringer&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162374</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162374"/>
		<updated>2025-03-24T21:08:01Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Proposed System==&lt;br /&gt;
The primary objective of this project is to modify the Submission Record Controller so that submission records become visible to students. Previously, only instructors had access to these records. The key deliverables include:&lt;br /&gt;
&lt;br /&gt;
1. Updating the access control logic to grant students permission to view their own submission records.&lt;br /&gt;
&lt;br /&gt;
2. Ensuring students cannot access other teams’ submission records.&lt;br /&gt;
&lt;br /&gt;
3. Modifying the UI to present submission history in an intuitive manner.&lt;br /&gt;
&lt;br /&gt;
4. Updating API routes and database queries to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
5. Writing and executing test cases to validate the changes.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
&lt;br /&gt;
==Files Involved==&lt;br /&gt;
&lt;br /&gt;
*app/controllers/submission_records_controller.rb&lt;br /&gt;
*app/models/submission_record.rb&lt;br /&gt;
*app/views/student_task/list.html.erb&lt;br /&gt;
*app/views/submission_records/index.html.erb&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
1. Identify the Existing Access Control Mechanism:&lt;br /&gt;
We examined the existing authorization logic that restricted students from viewing their own submission records.&lt;br /&gt;
Access permissions were defined at the controller level, requiring updates to include student roles.&lt;br /&gt;
&lt;br /&gt;
2.Modify the Submission Record Controller:&lt;br /&gt;
We modified the controller to allow students to retrieve their own submission records while ensuring security constraints.&lt;br /&gt;
&lt;br /&gt;
Role-based conditions were implemented to prevent unauthorized access.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-controller.png|400px]]&lt;br /&gt;
&lt;br /&gt;
3.Update Submission-Records View for Students:&lt;br /&gt;
A new student-friendly interface was added to display submission history. &lt;br /&gt;
&lt;br /&gt;
The UI was updated to ensure that students could only access records linked to their own submissions.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-views.png|400px]]&lt;br /&gt;
&lt;br /&gt;
4.Create a New View for Submission Records:&lt;br /&gt;
A separate view was introduced to present submission records in a structured format.&lt;br /&gt;
&lt;br /&gt;
This view mirrors the instructor’s interface but with restricted data access.&lt;br /&gt;
&lt;br /&gt;
[[File:submission-records-students-views.png|400px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5.Update API Routes in config/routes.rb:&lt;br /&gt;
New API endpoints were configured to fetch relevant submission data for students. The changes ensured compatibility with the existing API architecture.&lt;br /&gt;
&lt;br /&gt;
6.Perform Testing Using RSpec:&lt;br /&gt;
We wrote unit and integration tests to verify that the new functionality worked as expected. These tests ensured that students could only access their own submission records.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/WintersLt/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ The Live Expertiza Website]&lt;br /&gt;
&lt;br /&gt;
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Project Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://relishapp.com/rspec RSpec Documentation]&lt;br /&gt;
&lt;br /&gt;
Clean Code: A Handbook of Agile Software Craftsmanship – Robert C. Martin&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
Priya Gandhi, Saisumanth Tallapragada, Delaney Dow&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
Anirudha Rajenkar, Ed Grehringer&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162365</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162365"/>
		<updated>2025-03-24T20:44:16Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
=== Ruby on Rails ===&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The primary objective of this project is to modify the Submission Record Controller so that submission records become visible to students. Previously, only instructors had access to these records. The key deliverables include:&lt;br /&gt;
&lt;br /&gt;
1. Updating the access control logic to grant students permission to view their own submission records.&lt;br /&gt;
&lt;br /&gt;
2. Ensuring students cannot access other teams’ submission records.&lt;br /&gt;
&lt;br /&gt;
3. Modifying the UI to present submission history in an intuitive manner.&lt;br /&gt;
&lt;br /&gt;
4. Updating API routes and database queries to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
5. Writing and executing test cases to validate the changes.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
Design patterns are not applicable as our task involved just implementing a method. However, the [[CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records#Implementation|Implementation]] section below provides details of the steps as why it was implemented, the way it was implemented.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
1. Identify the Existing Access Control Mechanism:&lt;br /&gt;
We examined the existing authorization logic that restricted students from viewing their own submission records.&lt;br /&gt;
Access permissions were defined at the controller level, requiring updates to include student roles.&lt;br /&gt;
&lt;br /&gt;
2.Modify the Submission Record Controller:&lt;br /&gt;
We modified the controller to allow students to retrieve their own submission records while ensuring security constraints.&lt;br /&gt;
Role-based conditions were implemented to prevent unauthorized access.&lt;br /&gt;
[[File:submission-records-controller.png|600px]]&lt;br /&gt;
&lt;br /&gt;
3.Update Submission-Records View for Students:&lt;br /&gt;
A new student-friendly interface was added to display submission history. &lt;br /&gt;
The UI was updated to ensure that students could only access records linked to their own submissions.&lt;br /&gt;
[[File:submission-records-views.png|700px]]&lt;br /&gt;
&lt;br /&gt;
4.Create a New View for Submission Records:&lt;br /&gt;
A separate view was introduced to present submission records in a structured format.&lt;br /&gt;
This view mirrors the instructor’s interface but with restricted data access.&lt;br /&gt;
[[File:submission-records-students-views.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5.Update API Routes in config/routes.rb:&lt;br /&gt;
New API endpoints were configured to fetch relevant submission data for students.&lt;br /&gt;
The changes ensured compatibility with the existing API architecture.&lt;br /&gt;
&lt;br /&gt;
6.Perform Testing Using RSpec:&lt;br /&gt;
We wrote unit and integration tests to verify that the new functionality worked as expected.&lt;br /&gt;
These tests ensured that students could only access their own submission records.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/expertiza/expertiza Expertiza on GitHub]&lt;br /&gt;
&lt;br /&gt;
[https://github.com/WintersLt/expertiza GitHub Project Repository Fork]&lt;br /&gt;
&lt;br /&gt;
[http://expertiza.ncsu.edu/ The Live Expertiza Website]&lt;br /&gt;
&lt;br /&gt;
[http://bit.ly/myexpertiza Demo Link]&lt;br /&gt;
&lt;br /&gt;
[http://wikis.lib.ncsu.edu/index.php/Expertiza Expertiza Project Documentation]&lt;br /&gt;
&lt;br /&gt;
[https://relishapp.com/rspec RSpec Documentation]&lt;br /&gt;
&lt;br /&gt;
Clean Code: A Handbook of Agile Software Craftsmanship – Robert C. Martin&lt;br /&gt;
&lt;br /&gt;
==Team Members==&lt;br /&gt;
Priya Gandhi, Saisumanth Tallapragda, Delaney Dow&lt;br /&gt;
&lt;br /&gt;
===Mentors===&lt;br /&gt;
Anirudha Rajenkar, Ed Grehringer&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162363</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162363"/>
		<updated>2025-03-24T20:41:23Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
=== Ruby on Rails ===&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The primary objective of this project is to modify the Submission Record Controller so that submission records become visible to students. Previously, only instructors had access to these records. The key deliverables include:&lt;br /&gt;
&lt;br /&gt;
1. Updating the access control logic to grant students permission to view their own submission records.&lt;br /&gt;
&lt;br /&gt;
2. Ensuring students cannot access other teams’ submission records.&lt;br /&gt;
&lt;br /&gt;
3. Modifying the UI to present submission history in an intuitive manner.&lt;br /&gt;
&lt;br /&gt;
4. Updating API routes and database queries to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
5. Writing and executing test cases to validate the changes.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
Design patterns are not applicable as our task involved just implementing a method. However, the [[CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records#Implementation|Implementation]] section below provides details of the steps as why it was implemented, the way it was implemented.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
1. Identify the Existing Access Control Mechanism:&lt;br /&gt;
We examined the existing authorization logic that restricted students from viewing their own submission records.&lt;br /&gt;
Access permissions were defined at the controller level, requiring updates to include student roles.&lt;br /&gt;
&lt;br /&gt;
2.Modify the Submission Record Controller:&lt;br /&gt;
We modified the controller to allow students to retrieve their own submission records while ensuring security constraints.&lt;br /&gt;
Role-based conditions were implemented to prevent unauthorized access.&lt;br /&gt;
[[File:submission-records-controller.png|600px]]&lt;br /&gt;
&lt;br /&gt;
3.Update Submission-Records View for Students:&lt;br /&gt;
A new student-friendly interface was added to display submission history. &lt;br /&gt;
The UI was updated to ensure that students could only access records linked to their own submissions.&lt;br /&gt;
[[File:submission-records-views.png|700px]]&lt;br /&gt;
&lt;br /&gt;
4.Create a New View for Submission Records:&lt;br /&gt;
A separate view was introduced to present submission records in a structured format.&lt;br /&gt;
This view mirrors the instructor’s interface but with restricted data access.&lt;br /&gt;
[[File:submission-records-students-views.png|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5.Update API Routes in config/routes.rb:&lt;br /&gt;
New API endpoints were configured to fetch relevant submission data for students.&lt;br /&gt;
The changes ensured compatibility with the existing API architecture.&lt;br /&gt;
&lt;br /&gt;
6.Perform Testing Using RSpec:&lt;br /&gt;
We wrote unit and integration tests to verify that the new functionality worked as expected.&lt;br /&gt;
These tests ensured that students could only access their own submission records.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162362</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162362"/>
		<updated>2025-03-24T20:40:44Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
=== Ruby on Rails ===&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The primary objective of this project is to modify the Submission Record Controller so that submission records become visible to students. Previously, only instructors had access to these records. The key deliverables include:&lt;br /&gt;
&lt;br /&gt;
1. Updating the access control logic to grant students permission to view their own submission records.&lt;br /&gt;
&lt;br /&gt;
2. Ensuring students cannot access other teams’ submission records.&lt;br /&gt;
&lt;br /&gt;
3. Modifying the UI to present submission history in an intuitive manner.&lt;br /&gt;
&lt;br /&gt;
4. Updating API routes and database queries to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
5. Writing and executing test cases to validate the changes.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
Design patterns are not applicable as our task involved just implementing a method. However, the [[CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records#Implementation|Implementation]] section below provides details of the steps as why it was implemented, the way it was implemented.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
1. Identify the Existing Access Control Mechanism:&lt;br /&gt;
We examined the existing authorization logic that restricted students from viewing their own submission records.&lt;br /&gt;
Access permissions were defined at the controller level, requiring updates to include student roles.&lt;br /&gt;
&lt;br /&gt;
2.Modify the Submission Record Controller:&lt;br /&gt;
We modified the controller to allow students to retrieve their own submission records while ensuring security constraints.&lt;br /&gt;
Role-based conditions were implemented to prevent unauthorized access.&lt;br /&gt;
[[File:submission-records-controller.png|600px]]&lt;br /&gt;
&lt;br /&gt;
3.Update Submission-Records View for Students:&lt;br /&gt;
A new student-friendly interface was added to display submission history. &lt;br /&gt;
The UI was updated to ensure that students could only access records linked to their own submissions.&lt;br /&gt;
[[File:submission-records-views.png|600px]]&lt;br /&gt;
&lt;br /&gt;
4.Create a New View for Submission Records:&lt;br /&gt;
A separate view was introduced to present submission records in a structured format.&lt;br /&gt;
This view mirrors the instructor’s interface but with restricted data access.&lt;br /&gt;
[[File:submission-records-students-views.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5.Update API Routes in config/routes.rb:&lt;br /&gt;
New API endpoints were configured to fetch relevant submission data for students.&lt;br /&gt;
The changes ensured compatibility with the existing API architecture.&lt;br /&gt;
&lt;br /&gt;
6.Perform Testing Using RSpec:&lt;br /&gt;
We wrote unit and integration tests to verify that the new functionality worked as expected.&lt;br /&gt;
These tests ensured that students could only access their own submission records.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162361</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162361"/>
		<updated>2025-03-24T20:39:44Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
=== Ruby on Rails ===&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The primary objective of this project is to modify the Submission Record Controller so that submission records become visible to students. Previously, only instructors had access to these records. The key deliverables include:&lt;br /&gt;
&lt;br /&gt;
1. Updating the access control logic to grant students permission to view their own submission records.&lt;br /&gt;
&lt;br /&gt;
2. Ensuring students cannot access other teams’ submission records.&lt;br /&gt;
&lt;br /&gt;
3. Modifying the UI to present submission history in an intuitive manner.&lt;br /&gt;
&lt;br /&gt;
4. Updating API routes and database queries to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
5. Writing and executing test cases to validate the changes.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
Design patterns are not applicable as our task involved just implementing a method. However, the [[CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records#Implementation|Implementation]] section below provides details of the steps as why it was implemented, the way it was implemented.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
1. Identify the Existing Access Control Mechanism:&lt;br /&gt;
We examined the existing authorization logic that restricted students from viewing their own submission records.&lt;br /&gt;
Access permissions were defined at the controller level, requiring updates to include student roles.&lt;br /&gt;
&lt;br /&gt;
2.Modify the Submission Record Controller:&lt;br /&gt;
We modified the controller to allow students to retrieve their own submission records while ensuring security constraints.&lt;br /&gt;
Role-based conditions were implemented to prevent unauthorized access.&lt;br /&gt;
[[File:submission-records-controller.png|600px]]&lt;br /&gt;
&lt;br /&gt;
3.Update Submission-Records View for Students:&lt;br /&gt;
A new student-friendly interface was added to display submission history. &lt;br /&gt;
The UI was updated to ensure that students could only access records linked to their own submissions.&lt;br /&gt;
[[File:submission-records-views.png|500px]]&lt;br /&gt;
&lt;br /&gt;
4.Create a New View for Submission Records:&lt;br /&gt;
A separate view was introduced to present submission records in a structured format.&lt;br /&gt;
This view mirrors the instructor’s interface but with restricted data access.&lt;br /&gt;
[[File:submission-records-students-views.png|500px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5.Update API Routes in config/routes.rb:&lt;br /&gt;
New API endpoints were configured to fetch relevant submission data for students.&lt;br /&gt;
The changes ensured compatibility with the existing API architecture.&lt;br /&gt;
&lt;br /&gt;
6.Perform Testing Using RSpec:&lt;br /&gt;
We wrote unit and integration tests to verify that the new functionality worked as expected.&lt;br /&gt;
These tests ensured that students could only access their own submission records.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162359</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162359"/>
		<updated>2025-03-24T20:33:57Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
=== Ruby on Rails ===&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The primary objective of this project is to modify the Submission Record Controller so that submission records become visible to students. Previously, only instructors had access to these records. The key deliverables include:&lt;br /&gt;
&lt;br /&gt;
Updating the access control logic to grant students permission to view their own submission records.&lt;br /&gt;
&lt;br /&gt;
Ensuring students cannot access other teams’ submission records.&lt;br /&gt;
&lt;br /&gt;
Modifying the UI to present submission history in an intuitive manner.&lt;br /&gt;
&lt;br /&gt;
Updating API routes and database queries to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
Writing and executing test cases to validate the changes.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
Design patterns are not applicable as our task involved just implementing a method. However, the [[CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records#Implementation|Implementation]] section below provides details of the steps as why it was implemented, the way it was implemented.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Identify the existing access control mechanism that restricts students from viewing their submission records.&lt;br /&gt;
&lt;br /&gt;
Modified the Submission Record Controller to allow students to view their own submission records while maintaining appropriate permissions.&lt;br /&gt;
[[File:submission-records-controller.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Updated Submission-records view for students to see history of their submission for each assignment.&lt;br /&gt;
[[File:submission-records-views.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Created a new view to display submission records for students.                                 &lt;br /&gt;
[[File:submission-records-students-views.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Updated paths in config/routes.rb for API responses to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
Performed testing using Rspec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162358</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162358"/>
		<updated>2025-03-24T20:32:11Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
=== Ruby on Rails ===&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
=== Expertiza's Existing Submission Records Feature ===&lt;br /&gt;
In the existing Expertiza system, instructors are provided with detailed submission history for each assignment. This allows instructors to track the progress of students, view their submissions, and monitor whether students have completed their assignments on time. However, this feature was restricted to instructors only, leaving students without visibility into their own submission records. This limitation often made it challenging for students to track their progress or verify that their submissions were properly recorded, especially in case of discrepancies or issues with the submission system.&lt;br /&gt;
&lt;br /&gt;
With this project, the goal is to extend this feature, allowing students to view their own submission history, which will improve transparency and provide them with better control over their assignments.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The goal of this project is to modify the Submission Record Controller so that submission records are visible to students as well, whereas currently, they are only accessible to instructors.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
Design patterns are not applicable as our task involved just implementing a method. However, the [[CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records#Implementation|Implementation]] section below provides details of the steps as why it was implemented, the way it was implemented.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Identify the existing access control mechanism that restricts students from viewing their submission records.&lt;br /&gt;
&lt;br /&gt;
Modified the Submission Record Controller to allow students to view their own submission records while maintaining appropriate permissions.&lt;br /&gt;
[[File:submission-records-controller.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Updated Submission-records view for students to see history of their submission for each assignment.&lt;br /&gt;
[[File:submission-records-views.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Created a new view to display submission records for students.                                 &lt;br /&gt;
[[File:submission-records-students-views.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Updated paths in config/routes.rb for API responses to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
Performed testing using Rspec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
===Automated Testing using RSPEC===&lt;br /&gt;
The current version of expertiza backend reimplementation did not have a testing suite for the Submission Records controller, or the submission record model that tested the extended student functionality that we added. Using a combination of the test driven development(TDD) and behavior driven design (BDD) approach, we added in RSpec testing for the SubmissionRecordsController and Submission model files that tested our modifications. The student functionality was only added and tested exhaustively since the instructor and admin functionality has already been developed. Since the controller was designed for APIs and returning all HTTP calls when appropriate, this was integrated into the testing framework to check as well. The testing suite is compatible with APIs and swagger framework according the the project document specifications. &lt;br /&gt;
&lt;br /&gt;
====Example review of test cases====&lt;br /&gt;
The below code is an example of some of the testing structure for the RSpec testing. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 # GET /api/v1/student_task (Get student tasks)&lt;br /&gt;
&lt;br /&gt;
  describe 'GET /submission_records/:id' do&lt;br /&gt;
    context 'when the student is part of the team' do&lt;br /&gt;
      it 'allows access and returns a 200 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: valid_headers&lt;br /&gt;
        expect(response).to have_http_status(:ok)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when the student is NOT part of the team' do&lt;br /&gt;
      it 'denies access and returns a 403 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: unauthorized_headers&lt;br /&gt;
        expect(response).to have_http_status(:forbidden)&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    context 'when an invalid token is provided' do&lt;br /&gt;
      it 'returns a 401 status' do&lt;br /&gt;
        get &amp;quot;/submission_records/#{submission_record.id}&amp;quot;, headers: invalid_headers&lt;br /&gt;
        expect(response).to have_http_status(:unauthorized)&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;
&lt;br /&gt;
====Executing test cases====&lt;br /&gt;
The tests can be executed &amp;quot;rpec spec&amp;quot; command as shown below, and works best when set up locally or via Docker.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bundle install&lt;br /&gt;
rake db:create:all&lt;br /&gt;
rake db:migrate&lt;br /&gt;
rails s&lt;br /&gt;
.&lt;br /&gt;
user-expertiza/backend-reimplementation $rspec spec&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
.&lt;br /&gt;
Finished in 5.39 seconds (files took 25.33 seconds to load)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Testing from UI===&lt;br /&gt;
The only UI changes that were made included added a student view that mimics the instructor view. The view path 'app/view/submission_records' represents this. The added functionality ensures that, when logged in as a student, only those students who are associated with the team of that specific assignment that has been submitted can view the record.&lt;br /&gt;
 &lt;br /&gt;
1. When logged in as Student A, navigate to the student task list, where there will be a column that links to the submission record view. &lt;br /&gt;
&lt;br /&gt;
2. By clicking on the submission record column, student A will then be able to see the submission record history, if applicable. &lt;br /&gt;
   &lt;br /&gt;
3. When logging in as student B who is not associated with the team that the assignment/submission record is linked to, they will not be able to see any submission records.&lt;br /&gt;
&lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162344</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162344"/>
		<updated>2025-03-24T20:06:12Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
=== Ruby on Rails ===&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The goal of this project is to modify the Submission Record Controller so that submission records are visible to students as well, whereas currently, they are only accessible to instructors.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
Design patterns are not applicable as our task involved just implementing a method. However, the [[CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records#Implementation|Implementation]] section below provides details of the steps as why it was implemented, the way it was implemented.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Identify the existing access control mechanism that restricts students from viewing their submission records.&lt;br /&gt;
&lt;br /&gt;
Modified the Submission Record Controller to allow students to view their own submission records while maintaining appropriate permissions.&lt;br /&gt;
[[File:submission-records-controller.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Updated Submission-records view for students to see history of their submission for each assignment.&lt;br /&gt;
[[File:submission-records-views.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Created a new view to display submission records for students.                                 &lt;br /&gt;
[[File:submission-records-students-views.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Updated paths in config/routes.rb for API responses to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
Performed testing using Rspec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Following are the steps to run all the tests for XMLHttpRequest:&lt;br /&gt;
&lt;br /&gt;
# Install the pre-requisites required for servo as mentioned [https://github.com/servo/servo/blob/master/README.md here] &lt;br /&gt;
# Run the following commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
  cd&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git checkout -b test origin/overrideMimeType&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: It may take around 30 mins to build&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach test-wpt XMLHttpRequest/ --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see that all tests pass as expected.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' We have not added any new tests to the test suite as servo follows TDD and tests were previously written for XMLHttpRequest. We have just adjusted some of the test expectations for the tests which now pass due to our implementation.&lt;br /&gt;
&lt;br /&gt;
=== Testing From UI ===&lt;br /&gt;
&lt;br /&gt;
Our project cannot be tested from UI since it is basically improving some javascript features (XMLHttpRequest) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
Run the following command after the project is build: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162342</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162342"/>
		<updated>2025-03-24T20:04:22Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
=== Ruby on Rails ===&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The goal of this project is to modify the Submission Record Controller so that submission records are visible to students as well, whereas currently, they are only accessible to instructors.&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
Design patterns are not applicable as our task involved just implementing a method. However, the [[CSC/ECE_517_Spring_2025/oss_E2507#Implementation|Implementation]] section below provides details of the steps as why it was implemented, the way it was implemented.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Identify the existing access control mechanism that restricts students from viewing their submission records.&lt;br /&gt;
&lt;br /&gt;
Modified the Submission Record Controller to allow students to view their own submission records while maintaining appropriate permissions.&lt;br /&gt;
[[File:submission-records-controller.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Updated Submission-records view for students to see history of their submission for each assignment.&lt;br /&gt;
[[File:submission-records-views.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Created a new view to display submission records for students.                                 &lt;br /&gt;
[[File:submission-records-students-views.png|500px]]&lt;br /&gt;
&lt;br /&gt;
Updated paths in config/routes.rb for API responses to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
Performed testing using Rspec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Following are the steps to run all the tests for XMLHttpRequest:&lt;br /&gt;
&lt;br /&gt;
# Install the pre-requisites required for servo as mentioned [https://github.com/servo/servo/blob/master/README.md here] &lt;br /&gt;
# Run the following commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
  cd&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git checkout -b test origin/overrideMimeType&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: It may take around 30 mins to build&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach test-wpt XMLHttpRequest/ --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see that all tests pass as expected.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' We have not added any new tests to the test suite as servo follows TDD and tests were previously written for XMLHttpRequest. We have just adjusted some of the test expectations for the tests which now pass due to our implementation.&lt;br /&gt;
&lt;br /&gt;
=== Testing From UI ===&lt;br /&gt;
&lt;br /&gt;
Our project cannot be tested from UI since it is basically improving some javascript features (XMLHttpRequest) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
Run the following command after the project is build: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/expertiza/reimplementation-back-end/pull/175 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission-records-students-views.png&amp;diff=162338</id>
		<title>File:Submission-records-students-views.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission-records-students-views.png&amp;diff=162338"/>
		<updated>2025-03-24T19:53:23Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission-records-views.png&amp;diff=162337</id>
		<title>File:Submission-records-views.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission-records-views.png&amp;diff=162337"/>
		<updated>2025-03-24T19:52:47Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission-records-controller.png&amp;diff=162336</id>
		<title>File:Submission-records-controller.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Submission-records-controller.png&amp;diff=162336"/>
		<updated>2025-03-24T19:51:53Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162334</id>
		<title>CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2507._Reimplement_back_end_for_submission_records&amp;diff=162334"/>
		<updated>2025-03-24T19:43:25Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: Created page with &amp;quot;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt; Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.  ==Introduction== === Ruby on Rails === Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over conf...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;E2507. Reimplement back end for submission records&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Currently only instructors can see the submission history of the participants of particular assignment currently. The goal of this project is to extend submission records to students.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
=== Ruby on Rails ===&lt;br /&gt;
Ruby on Rails (Rails) is a server-side web application framework written in Ruby that follows the MVC (Model-View-Controller) architecture. It emphasizes convention over configuration, making web development faster and more efficient by providing built-in tools for common tasks like database management, routing, and authentication.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Scope==&lt;br /&gt;
The goal of this project is to modify the Submission Record Controller so that submission records are visible to students as well, whereas currently, they are only accessible to instructors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Design Pattern==&lt;br /&gt;
Design patterns are not applicable as our task involved just implementing a method. However, the [[CSC/ECE_517_Spring_2025/oss_E2507#Implementation|Implementation]] section below provides details of the steps as why it was implemented, the way it was implemented.&lt;br /&gt;
&lt;br /&gt;
==Implementation==&lt;br /&gt;
Identify the existing access control mechanism that restricts students from viewing their submission records.&lt;br /&gt;
&lt;br /&gt;
Modified the Submission Record Controller to allow students to view their own submission records while maintaining appropriate permissions.&lt;br /&gt;
[[File:submission-records-controller.png]]&lt;br /&gt;
&lt;br /&gt;
Updated Submission-records view for students to see history of their submission for each assignment. &lt;br /&gt;
[[File:submission-records-views.png]]&lt;br /&gt;
&lt;br /&gt;
Created a new view to display submission records for students.&lt;br /&gt;
[[File:submission-records-students-views.png]]&lt;br /&gt;
&lt;br /&gt;
Updated paths in config/routes.rb for API responses to fetch the relevant submission data.&lt;br /&gt;
&lt;br /&gt;
Performed testing using Rspec.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Following are the steps to run all the tests for XMLHttpRequest:&lt;br /&gt;
&lt;br /&gt;
# Install the pre-requisites required for servo as mentioned [https://github.com/servo/servo/blob/master/README.md here] &lt;br /&gt;
# Run the following commands&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
  cd&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git clone https://github.com/jitendra29/servo.git&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 cd servo&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 git checkout -b test origin/overrideMimeType&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach build --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: It may take around 30 mins to build&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach test-wpt XMLHttpRequest/ --release&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see that all tests pass as expected.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' We have not added any new tests to the test suite as servo follows TDD and tests were previously written for XMLHttpRequest. We have just adjusted some of the test expectations for the tests which now pass due to our implementation.&lt;br /&gt;
&lt;br /&gt;
=== Testing From UI ===&lt;br /&gt;
&lt;br /&gt;
Our project cannot be tested from UI since it is basically improving some javascript features (XMLHttpRequest) in servo. However you can check that it doesn't break the existing code and the browser runs correctly by running a test page on servo after performing the build as mentioned above.&lt;br /&gt;
&lt;br /&gt;
Run the following command after the project is build: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 ./mach run tests/html/about-mozilla.html&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
==Pull Request==&lt;br /&gt;
Here is our [https://github.com/servo/servo/pull/8182 pull request]. In the link you can see all code snippets changed due to implementing the above steps, as well as integration test progression information.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025&amp;diff=161936</id>
		<title>CSC/ECE 517 Spring 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025&amp;diff=161936"/>
		<updated>2025-03-23T17:55:29Z</updated>

		<summary type="html">&lt;p&gt;Pgandhi4: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* [[CSC/ECE 517 Spring 2025 - E2504. Mentor-meeting management]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2508. Reimplement bidding-algorithm web service]]&lt;br /&gt;
* [[CSC/ECE 517 Fall 2024 - E2519. Implement view for results of bidding]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2522. Enhancing UI Consistency in Expertiza 1]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2520. Reimplement heatgrid UI for reviews]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2517. Reimplement internationalization (frontend + backend)]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2523: Enhancing UI Consistency in Expertiza 2]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2515:  Reimplement student_teams_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2501:  Refactor review_mapping_helper.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2512. Reimplement responses controller]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2510. Reimplement grades_controller.rb]]&lt;br /&gt;
* [[CSC/ECE 517 Spring 2025 - E2507. Reimplement back end for submission records]]&lt;/div&gt;</summary>
		<author><name>Pgandhi4</name></author>
	</entry>
</feed>