<?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=Vdeo</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=Vdeo"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Vdeo"/>
	<updated>2026-05-23T20:28:58Z</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_-_E2528_Testing_for_Survey_Deployment&amp;diff=165119</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=165119"/>
		<updated>2025-04-23T03:22:54Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* 🔗 References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ====&lt;br /&gt;
This method returns an array of counts representing how many times each score (defined by the `@range_of_scores` variable) was selected in answers to a specific question within a given survey deployment. It does this by:&lt;br /&gt;
&lt;br /&gt;
* Identifying response maps linked to the survey deployment (supports types: Assignment, Course, Global).&lt;br /&gt;
* Fetching all responses from those maps.&lt;br /&gt;
* Counting how many times each score was recorded for the provided question across all responses.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
'''Scenario 1: Counts multiple answers of the same score'''&lt;br /&gt;
&lt;br /&gt;
 Validates that if multiple answers with the same score exist for a question, the count is aggregated correctly.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Returns all zeros if no answers exist'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the method returns a zero count array if there are no answers associated with the question.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Handles mixed score distribution'''&lt;br /&gt;
&lt;br /&gt;
 Tests the function's ability to correctly assign counts to different scores within the same response.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Aggregates across multiple response maps'''&lt;br /&gt;
&lt;br /&gt;
 Ensures answers from multiple response maps are all considered in the score aggregation.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: Returns zeros for invalid deployment ID'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that the method gracefully returns all zeros when given a non-existent survey deployment ID.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Raises error on invalid question ID'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that the method throws an `ActiveRecord::RecordNotFound` error if the question ID does not exist.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: Handles nil @range_of_scores'''&lt;br /&gt;
&lt;br /&gt;
 Tests the behavior when `@range_of_scores` is not defined. It should return an empty array without errors.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 8: Supports custom score range (e.g., 1 to 3)'''&lt;br /&gt;
&lt;br /&gt;
 Validates correct operation when a non-default range of scores is provided.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 9: Ignores answers with scores outside the range'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that scores not included in `@range_of_scores` are excluded from the count.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 10: Ignores answers with nil scores'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that answers with no score (nil) do not affect the result array.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 11: Returns zeros when response maps have no responses'''&lt;br /&gt;
&lt;br /&gt;
 Tests behavior when response maps exist but have no associated responses.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 12: Ignores answers from other questions'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that only answers corresponding to the specific question ID are counted.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 13: Handles high-volume datasets'''&lt;br /&gt;
&lt;br /&gt;
 Simulates performance with 50 responses and ensures results remain accurate.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 14: Works across supported response map types'''&lt;br /&gt;
&lt;br /&gt;
 Ensures compatibility with AssignmentSurveyResponseMap, CourseSurveyResponseMap, and GlobalSurveyResponseMap.&lt;br /&gt;
&lt;br /&gt;
=== Method: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ====&lt;br /&gt;
This method determines whether a given question type is eligible for statistical analysis in the UI. According to the application logic, only questions of type `'Criterion'` and `'Checkbox'` are valid for such calculations.&lt;br /&gt;
&lt;br /&gt;
It returns:&lt;br /&gt;
* `true` for questions of type `'Criterion'` or `'Checkbox'`&lt;br /&gt;
* `false` for any other type, including unknown, `nil`, or incorrectly formatted inputs&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: Accepts &amp;quot;Criterion&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that the method returns `true` when the question type is `'Criterion'`, which is allowed for statistical reporting.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Accepts &amp;quot;Checkbox&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that `'Checkbox'` is recognized as a valid statistical question type and returns `true`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Rejects &amp;quot;TextArea&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
 Validates that unsupported question types such as `'TextArea'` are rejected and return `false`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Rejects nil as type'''&lt;br /&gt;
&lt;br /&gt;
 Checks that if a question has a `nil` type, the method returns `false` without error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: Rejects empty string as type'''&lt;br /&gt;
&lt;br /&gt;
 Ensures empty strings (`''`) are not mistakenly treated as valid question types.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Rejects unknown types like &amp;quot;Dropdown&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the method returns `false` for unknown types not explicitly whitelisted (e.g., `'Dropdown'`).&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: Accepts real Criterion question instance'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that the method returns `true` when passed a real ActiveRecord question object of type `'Criterion'`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 8: Enforces case sensitivity'''&lt;br /&gt;
&lt;br /&gt;
 Checks that lowercase valid types (e.g., `'criterion'`) are rejected, ensuring type matching is case-sensitive.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 9: Rejects non-string type like symbol'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that a non-string type such as `:Criterion` is rejected, maintaining strict type checking.&lt;br /&gt;
&lt;br /&gt;
=Testing Details=&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/VibhavDeo/expertiza/blob/main/spec/models/survey_deployment_spec.rb survey_deployment_spec.rb] and [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb survey_deployment_helper_spec.rb].&lt;br /&gt;
&lt;br /&gt;
====How to See Test Coverage====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_helper_coverage_2025.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for both files&lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* Design patterns like SRP, OCP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results&lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/2955 Pull Request]&lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;br /&gt;
* [https://youtu.be/3ujM1Dzx9Q0 Demo]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164533</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164533"/>
		<updated>2025-04-22T03:32:30Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* 📈 Final Outcomes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ====&lt;br /&gt;
This method returns an array of counts representing how many times each score (defined by the `@range_of_scores` variable) was selected in answers to a specific question within a given survey deployment. It does this by:&lt;br /&gt;
&lt;br /&gt;
* Identifying response maps linked to the survey deployment (supports types: Assignment, Course, Global).&lt;br /&gt;
* Fetching all responses from those maps.&lt;br /&gt;
* Counting how many times each score was recorded for the provided question across all responses.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
'''Scenario 1: Counts multiple answers of the same score'''&lt;br /&gt;
&lt;br /&gt;
 Validates that if multiple answers with the same score exist for a question, the count is aggregated correctly.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Returns all zeros if no answers exist'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the method returns a zero count array if there are no answers associated with the question.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Handles mixed score distribution'''&lt;br /&gt;
&lt;br /&gt;
 Tests the function's ability to correctly assign counts to different scores within the same response.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Aggregates across multiple response maps'''&lt;br /&gt;
&lt;br /&gt;
 Ensures answers from multiple response maps are all considered in the score aggregation.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: Returns zeros for invalid deployment ID'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that the method gracefully returns all zeros when given a non-existent survey deployment ID.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Raises error on invalid question ID'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that the method throws an `ActiveRecord::RecordNotFound` error if the question ID does not exist.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: Handles nil @range_of_scores'''&lt;br /&gt;
&lt;br /&gt;
 Tests the behavior when `@range_of_scores` is not defined. It should return an empty array without errors.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 8: Supports custom score range (e.g., 1 to 3)'''&lt;br /&gt;
&lt;br /&gt;
 Validates correct operation when a non-default range of scores is provided.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 9: Ignores answers with scores outside the range'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that scores not included in `@range_of_scores` are excluded from the count.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 10: Ignores answers with nil scores'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that answers with no score (nil) do not affect the result array.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 11: Returns zeros when response maps have no responses'''&lt;br /&gt;
&lt;br /&gt;
 Tests behavior when response maps exist but have no associated responses.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 12: Ignores answers from other questions'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that only answers corresponding to the specific question ID are counted.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 13: Handles high-volume datasets'''&lt;br /&gt;
&lt;br /&gt;
 Simulates performance with 50 responses and ensures results remain accurate.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 14: Works across supported response map types'''&lt;br /&gt;
&lt;br /&gt;
 Ensures compatibility with AssignmentSurveyResponseMap, CourseSurveyResponseMap, and GlobalSurveyResponseMap.&lt;br /&gt;
&lt;br /&gt;
=== Method: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ====&lt;br /&gt;
This method determines whether a given question type is eligible for statistical analysis in the UI. According to the application logic, only questions of type `'Criterion'` and `'Checkbox'` are valid for such calculations.&lt;br /&gt;
&lt;br /&gt;
It returns:&lt;br /&gt;
* `true` for questions of type `'Criterion'` or `'Checkbox'`&lt;br /&gt;
* `false` for any other type, including unknown, `nil`, or incorrectly formatted inputs&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: Accepts &amp;quot;Criterion&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that the method returns `true` when the question type is `'Criterion'`, which is allowed for statistical reporting.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Accepts &amp;quot;Checkbox&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that `'Checkbox'` is recognized as a valid statistical question type and returns `true`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Rejects &amp;quot;TextArea&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
 Validates that unsupported question types such as `'TextArea'` are rejected and return `false`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Rejects nil as type'''&lt;br /&gt;
&lt;br /&gt;
 Checks that if a question has a `nil` type, the method returns `false` without error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: Rejects empty string as type'''&lt;br /&gt;
&lt;br /&gt;
 Ensures empty strings (`''`) are not mistakenly treated as valid question types.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Rejects unknown types like &amp;quot;Dropdown&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the method returns `false` for unknown types not explicitly whitelisted (e.g., `'Dropdown'`).&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: Accepts real Criterion question instance'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that the method returns `true` when passed a real ActiveRecord question object of type `'Criterion'`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 8: Enforces case sensitivity'''&lt;br /&gt;
&lt;br /&gt;
 Checks that lowercase valid types (e.g., `'criterion'`) are rejected, ensuring type matching is case-sensitive.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 9: Rejects non-string type like symbol'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that a non-string type such as `:Criterion` is rejected, maintaining strict type checking.&lt;br /&gt;
&lt;br /&gt;
=Testing Details=&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/VibhavDeo/expertiza/blob/main/spec/models/survey_deployment_spec.rb survey_deployment_spec.rb] and [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb survey_deployment_helper_spec.rb].&lt;br /&gt;
&lt;br /&gt;
====How to See Test Coverage====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_helper_coverage_2025.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for both files&lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* Design patterns like SRP, OCP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results&lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/2955 Pull Request]&lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164532</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164532"/>
		<updated>2025-04-22T03:31:56Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Test Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ====&lt;br /&gt;
This method returns an array of counts representing how many times each score (defined by the `@range_of_scores` variable) was selected in answers to a specific question within a given survey deployment. It does this by:&lt;br /&gt;
&lt;br /&gt;
* Identifying response maps linked to the survey deployment (supports types: Assignment, Course, Global).&lt;br /&gt;
* Fetching all responses from those maps.&lt;br /&gt;
* Counting how many times each score was recorded for the provided question across all responses.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
'''Scenario 1: Counts multiple answers of the same score'''&lt;br /&gt;
&lt;br /&gt;
 Validates that if multiple answers with the same score exist for a question, the count is aggregated correctly.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Returns all zeros if no answers exist'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the method returns a zero count array if there are no answers associated with the question.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Handles mixed score distribution'''&lt;br /&gt;
&lt;br /&gt;
 Tests the function's ability to correctly assign counts to different scores within the same response.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Aggregates across multiple response maps'''&lt;br /&gt;
&lt;br /&gt;
 Ensures answers from multiple response maps are all considered in the score aggregation.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: Returns zeros for invalid deployment ID'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that the method gracefully returns all zeros when given a non-existent survey deployment ID.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Raises error on invalid question ID'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that the method throws an `ActiveRecord::RecordNotFound` error if the question ID does not exist.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: Handles nil @range_of_scores'''&lt;br /&gt;
&lt;br /&gt;
 Tests the behavior when `@range_of_scores` is not defined. It should return an empty array without errors.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 8: Supports custom score range (e.g., 1 to 3)'''&lt;br /&gt;
&lt;br /&gt;
 Validates correct operation when a non-default range of scores is provided.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 9: Ignores answers with scores outside the range'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that scores not included in `@range_of_scores` are excluded from the count.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 10: Ignores answers with nil scores'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that answers with no score (nil) do not affect the result array.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 11: Returns zeros when response maps have no responses'''&lt;br /&gt;
&lt;br /&gt;
 Tests behavior when response maps exist but have no associated responses.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 12: Ignores answers from other questions'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that only answers corresponding to the specific question ID are counted.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 13: Handles high-volume datasets'''&lt;br /&gt;
&lt;br /&gt;
 Simulates performance with 50 responses and ensures results remain accurate.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 14: Works across supported response map types'''&lt;br /&gt;
&lt;br /&gt;
 Ensures compatibility with AssignmentSurveyResponseMap, CourseSurveyResponseMap, and GlobalSurveyResponseMap.&lt;br /&gt;
&lt;br /&gt;
=== Method: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ====&lt;br /&gt;
This method determines whether a given question type is eligible for statistical analysis in the UI. According to the application logic, only questions of type `'Criterion'` and `'Checkbox'` are valid for such calculations.&lt;br /&gt;
&lt;br /&gt;
It returns:&lt;br /&gt;
* `true` for questions of type `'Criterion'` or `'Checkbox'`&lt;br /&gt;
* `false` for any other type, including unknown, `nil`, or incorrectly formatted inputs&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: Accepts &amp;quot;Criterion&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that the method returns `true` when the question type is `'Criterion'`, which is allowed for statistical reporting.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Accepts &amp;quot;Checkbox&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that `'Checkbox'` is recognized as a valid statistical question type and returns `true`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Rejects &amp;quot;TextArea&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
 Validates that unsupported question types such as `'TextArea'` are rejected and return `false`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Rejects nil as type'''&lt;br /&gt;
&lt;br /&gt;
 Checks that if a question has a `nil` type, the method returns `false` without error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: Rejects empty string as type'''&lt;br /&gt;
&lt;br /&gt;
 Ensures empty strings (`''`) are not mistakenly treated as valid question types.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Rejects unknown types like &amp;quot;Dropdown&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the method returns `false` for unknown types not explicitly whitelisted (e.g., `'Dropdown'`).&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: Accepts real Criterion question instance'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that the method returns `true` when passed a real ActiveRecord question object of type `'Criterion'`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 8: Enforces case sensitivity'''&lt;br /&gt;
&lt;br /&gt;
 Checks that lowercase valid types (e.g., `'criterion'`) are rejected, ensuring type matching is case-sensitive.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 9: Rejects non-string type like symbol'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that a non-string type such as `:Criterion` is rejected, maintaining strict type checking.&lt;br /&gt;
&lt;br /&gt;
=Testing Details=&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/VibhavDeo/expertiza/blob/main/spec/models/survey_deployment_spec.rb survey_deployment_spec.rb] and [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb survey_deployment_helper_spec.rb].&lt;br /&gt;
&lt;br /&gt;
====How to See Test Coverage====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_helper_coverage_2025.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/2955 Pull Request]&lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164531</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164531"/>
		<updated>2025-04-22T03:31:31Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Test Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ====&lt;br /&gt;
This method returns an array of counts representing how many times each score (defined by the `@range_of_scores` variable) was selected in answers to a specific question within a given survey deployment. It does this by:&lt;br /&gt;
&lt;br /&gt;
* Identifying response maps linked to the survey deployment (supports types: Assignment, Course, Global).&lt;br /&gt;
* Fetching all responses from those maps.&lt;br /&gt;
* Counting how many times each score was recorded for the provided question across all responses.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
'''Scenario 1: Counts multiple answers of the same score'''&lt;br /&gt;
&lt;br /&gt;
 Validates that if multiple answers with the same score exist for a question, the count is aggregated correctly.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Returns all zeros if no answers exist'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the method returns a zero count array if there are no answers associated with the question.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Handles mixed score distribution'''&lt;br /&gt;
&lt;br /&gt;
 Tests the function's ability to correctly assign counts to different scores within the same response.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Aggregates across multiple response maps'''&lt;br /&gt;
&lt;br /&gt;
 Ensures answers from multiple response maps are all considered in the score aggregation.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: Returns zeros for invalid deployment ID'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that the method gracefully returns all zeros when given a non-existent survey deployment ID.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Raises error on invalid question ID'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that the method throws an `ActiveRecord::RecordNotFound` error if the question ID does not exist.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: Handles nil @range_of_scores'''&lt;br /&gt;
&lt;br /&gt;
 Tests the behavior when `@range_of_scores` is not defined. It should return an empty array without errors.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 8: Supports custom score range (e.g., 1 to 3)'''&lt;br /&gt;
&lt;br /&gt;
 Validates correct operation when a non-default range of scores is provided.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 9: Ignores answers with scores outside the range'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that scores not included in `@range_of_scores` are excluded from the count.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 10: Ignores answers with nil scores'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that answers with no score (nil) do not affect the result array.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 11: Returns zeros when response maps have no responses'''&lt;br /&gt;
&lt;br /&gt;
 Tests behavior when response maps exist but have no associated responses.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 12: Ignores answers from other questions'''&lt;br /&gt;
&lt;br /&gt;
 Ensures that only answers corresponding to the specific question ID are counted.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 13: Handles high-volume datasets'''&lt;br /&gt;
&lt;br /&gt;
 Simulates performance with 50 responses and ensures results remain accurate.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 14: Works across supported response map types'''&lt;br /&gt;
&lt;br /&gt;
 Ensures compatibility with AssignmentSurveyResponseMap, CourseSurveyResponseMap, and GlobalSurveyResponseMap.&lt;br /&gt;
&lt;br /&gt;
=== Method: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ====&lt;br /&gt;
This method determines whether a given question type is eligible for statistical analysis in the UI. According to the application logic, only questions of type `'Criterion'` and `'Checkbox'` are valid for such calculations.&lt;br /&gt;
&lt;br /&gt;
It returns:&lt;br /&gt;
* `true` for questions of type `'Criterion'` or `'Checkbox'`&lt;br /&gt;
* `false` for any other type, including unknown, `nil`, or incorrectly formatted inputs&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: Accepts &amp;quot;Criterion&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
Confirms that the method returns `true` when the question type is `'Criterion'`, which is allowed for statistical reporting.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Accepts &amp;quot;Checkbox&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
Ensures that `'Checkbox'` is recognized as a valid statistical question type and returns `true`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Rejects &amp;quot;TextArea&amp;quot; type'''&lt;br /&gt;
&lt;br /&gt;
Validates that unsupported question types such as `'TextArea'` are rejected and return `false`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Rejects nil as type'''&lt;br /&gt;
&lt;br /&gt;
Checks that if a question has a `nil` type, the method returns `false` without error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: Rejects empty string as type'''&lt;br /&gt;
&lt;br /&gt;
Ensures empty strings (`''`) are not mistakenly treated as valid question types.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Rejects unknown types like &amp;quot;Dropdown&amp;quot;'''&lt;br /&gt;
&lt;br /&gt;
Tests that the method returns `false` for unknown types not explicitly whitelisted (e.g., `'Dropdown'`).&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: Accepts real Criterion question instance'''&lt;br /&gt;
&lt;br /&gt;
Confirms that the method returns `true` when passed a real ActiveRecord question object of type `'Criterion'`.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 8: Enforces case sensitivity'''&lt;br /&gt;
&lt;br /&gt;
Checks that lowercase valid types (e.g., `'criterion'`) are rejected, ensuring type matching is case-sensitive.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 9: Rejects non-string type like symbol'''&lt;br /&gt;
&lt;br /&gt;
Verifies that a non-string type such as `:Criterion` is rejected, maintaining strict type checking.&lt;br /&gt;
&lt;br /&gt;
=Testing Details=&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/VibhavDeo/expertiza/blob/main/spec/models/survey_deployment_spec.rb survey_deployment_spec.rb] and [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb survey_deployment_helper_spec.rb].&lt;br /&gt;
&lt;br /&gt;
====How to See Test Coverage====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_helper_coverage_2025.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/2955 Pull Request]&lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164506</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164506"/>
		<updated>2025-04-22T02:47:22Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* 🔗 References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Testing Details=&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/VibhavDeo/expertiza/blob/main/spec/models/survey_deployment_spec.rb survey_deployment_spec.rb] and [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb survey_deployment_helper_spec.rb].&lt;br /&gt;
&lt;br /&gt;
====How to See Test Coverage====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_helper_coverage_2025.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza/pull/2955 Pull Request]&lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164494</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164494"/>
		<updated>2025-04-22T02:38:40Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Testing Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Testing Details=&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/VibhavDeo/expertiza/blob/main/spec/models/survey_deployment_spec.rb survey_deployment_spec.rb] and [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb survey_deployment_helper_spec.rb].&lt;br /&gt;
&lt;br /&gt;
====How to See Test Coverage====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_helper_coverage_2025.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164493</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164493"/>
		<updated>2025-04-22T02:38:12Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Testing Details=&lt;br /&gt;
====Demo Videos====&lt;br /&gt;
# [https://drive.google.com/file/d/1UTeJC7oc8pbWZeOuCZt3JcdfW5uDv3Fu/view?usp=drive_link Demo Video for Tag Prompt Deployment Controller]&lt;br /&gt;
# [https://drive.google.com/file/d/1dJjeqZxuDon11R12YUp6UVXHD846Ogdz/view?usp=drive_link Demo Video for Answer Tags Controller]&lt;br /&gt;
&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/VibhavDeo/expertiza/blob/main/spec/models/survey_deployment_spec.rb survey_deployment_spec.rb] and [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb survey_deployment_helper_spec.rb].&lt;br /&gt;
&lt;br /&gt;
=====How to See Test Coverage=====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/VibhavDeo/expertiza/blob/main/spec/helpers/survey_deployment_helper_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_helper_coverage_2025.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164489</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164489"/>
		<updated>2025-04-22T02:34:57Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* survey_deployment_helper_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_helper_coverage_2025.png|800px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164488</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164488"/>
		<updated>2025-04-22T02:34:48Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* survey_deployment_helper_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_helper_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Survey_deployment_helper_coverage_2025.png&amp;diff=164487</id>
		<title>File:Survey deployment helper coverage 2025.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Survey_deployment_helper_coverage_2025.png&amp;diff=164487"/>
		<updated>2025-04-22T02:34:33Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164485</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164485"/>
		<updated>2025-04-22T02:34:15Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* survey_deployment_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|500px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164484</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164484"/>
		<updated>2025-04-22T02:34:06Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* survey_deployment_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Survey_deployment_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Survey_deployment_coverage_2025.png&amp;diff=164483</id>
		<title>File:Survey deployment coverage 2025.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Survey_deployment_coverage_2025.png&amp;diff=164483"/>
		<updated>2025-04-22T02:33:34Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164481</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164481"/>
		<updated>2025-04-22T02:32:36Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* survey_deployment_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.9&lt;br /&gt;
&lt;br /&gt;
[[File:Answer_tags_controller_coverage_2505.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164476</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164476"/>
		<updated>2025-04-22T02:30:52Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* survey_deployment_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 3.9&lt;br /&gt;
&lt;br /&gt;
[[File:Answer_tags_controller_coverage_2505.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164475</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164475"/>
		<updated>2025-04-22T02:29:02Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* survey_deployment_helper_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.7&lt;br /&gt;
&lt;br /&gt;
[[File:Answer_tags_controller_coverage_2505.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 47.5&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164472</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164472"/>
		<updated>2025-04-22T02:26:29Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
=Results=&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 1.7&lt;br /&gt;
&lt;br /&gt;
[[File:Answer_tags_controller_coverage_2505.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
====survey_deployment_helper_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 5.2&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164464</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164464"/>
		<updated>2025-04-22T02:20:45Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Validation Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164463</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164463"/>
		<updated>2025-04-22T02:20:18Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Abstract Method Tests */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
=== Validation Scenarios ===&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
 Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
 Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
 Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164462</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164462"/>
		<updated>2025-04-22T02:20:10Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Validation Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
=== Validation Scenarios ===&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
 Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
 Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
 Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
 Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164461</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164461"/>
		<updated>2025-04-22T02:19:55Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Validation Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
=== Validation Scenarios ===&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
 Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164460</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164460"/>
		<updated>2025-04-22T02:19:44Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Validation Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
=== Validation Scenarios ===&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
    Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164459</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164459"/>
		<updated>2025-04-22T02:19:33Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Validation Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
=== Validation Scenarios ===&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tabs&amp;gt;Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164458</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164458"/>
		<updated>2025-04-22T02:19:15Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Validation Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
=== Validation Scenarios ===&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tab&amp;gt;Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164457</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164457"/>
		<updated>2025-04-22T02:19:05Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Validation Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
=== Validation Scenarios ===&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
###Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164456</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164456"/>
		<updated>2025-04-22T02:18:38Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Validation Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
=== Validation Scenarios ===&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
#Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164455</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164455"/>
		<updated>2025-04-22T02:18:29Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Validation Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
=== Validation Scenarios ===&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
-Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164454</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=164454"/>
		<updated>2025-04-22T02:16:52Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Model: SurveyDeployment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates).&lt;br /&gt;
&lt;br /&gt;
When we received the project, there were no existing RSpec tests for the SurveyDeploymentHelper module. &lt;br /&gt;
&lt;br /&gt;
== Project Accomplishments ==  &lt;br /&gt;
Developed comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
** Created a new spec file for the helper module from scratch&lt;br /&gt;
** Achieved 100% test coverage&lt;br /&gt;
** Structured tests around SOLID principles&lt;br /&gt;
** Ensured coverage of edge cases and large dataset performance&lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || New file with complete helper test suite  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Testing Summary =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
=== Single Responsibility Principle (SRP) ===&lt;br /&gt;
Each method in the SurveyDeployment model is responsible for a distinct task.&lt;br /&gt;
&lt;br /&gt;
#The valid_start_end_time? method encapsulates all validation logic for date consistency.&lt;br /&gt;
#Abstract methods parent_name and response_maps are defined for implementation in child classes such as AssignmentSurveyDeployment and CourseSurveyDeployment.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) ===&lt;br /&gt;
The model is open for extension but closed for modification.&lt;br /&gt;
&lt;br /&gt;
#Abstract methods allow subclasses to define custom behavior without changing the base class logic.&lt;br /&gt;
#This promotes maintainability and adherence to polymorphic design.&lt;br /&gt;
&lt;br /&gt;
== Validation Logic ==&lt;br /&gt;
=== Method: valid_start_end_time? ===&lt;br /&gt;
Validates that:&lt;br /&gt;
&lt;br /&gt;
#Both start_date and end_date are present.&lt;br /&gt;
#end_date is after or equal to start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
== Test Scenarios ==&lt;br /&gt;
=== Validation Scenarios ===&lt;br /&gt;
'''Scenario 1: Missing start_date'''&lt;br /&gt;
&lt;br /&gt;
Tests that a SurveyDeployment is invalid if the start_date is not provided. It verifies that the appropriate error message is added to the model.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Missing end_date'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model is invalid when the end_date is missing. Confirms that the validation catches this case and produces a corresponding error.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Both start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
Checks the custom validation logic in valid_start_end_time? by omitting both start_date and end_date. The test confirms that a specific base-level error message is shown indicating both fields are required.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: end_date is before start_date'''&lt;br /&gt;
&lt;br /&gt;
Validates that the model correctly identifies when end_date is earlier than start_date and adds an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 5: end_date is in the past'''&lt;br /&gt;
&lt;br /&gt;
Confirms that a deployment is invalid if its end_date lies in the past (i.e., before the current time), ensuring the deployment period is always forward-looking.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 6: Valid start_date and end_date'''&lt;br /&gt;
&lt;br /&gt;
Tests a case with a valid start_date and a future end_date that follows it. The model should be valid in this scenario.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 7: start_date and end_date are the same'''&lt;br /&gt;
&lt;br /&gt;
Ensures the model allows deployments where both dates are the same, which is logically acceptable since the duration would be zero.&lt;br /&gt;
&lt;br /&gt;
== Abstract Method Tests ==&lt;br /&gt;
'''Scenario 1: Responds to parent_name'''&lt;br /&gt;
&lt;br /&gt;
Verifies that instances of SurveyDeployment respond to the parent_name method without raising an error, even though it is not implemented in the base class.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Responds to response_maps'''&lt;br /&gt;
&lt;br /&gt;
Similar to the above, this confirms that the SurveyDeployment base class defines the response_maps method as abstract and callable.&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: AssignmentSurveyDeployment returns associated response maps'''&lt;br /&gt;
&lt;br /&gt;
Tests that the AssignmentSurveyDeployment subclass implements the response_maps method properly and returns the expected response maps when queried using the instance’s ID.&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== SOLID Principles: === &lt;br /&gt;
&lt;br /&gt;
* SRP (Single Responsibility Principle):** Each method in the helper module is focused on one clear task.&lt;br /&gt;
* DIP (Dependency Inversion Principle):** All logic depends on external inputs via parameters, not internal hardcoded state, making the methods testable and modular.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Counts multiple answers of the same score correctly&lt;br /&gt;
&lt;br /&gt;
* Returns all zeros if no answers are given&lt;br /&gt;
&lt;br /&gt;
* Handles responses for mixed score values accurately&lt;br /&gt;
&lt;br /&gt;
* Aggregates across multiple response maps&lt;br /&gt;
&lt;br /&gt;
* Returns zeros for invalid deployment ID&lt;br /&gt;
&lt;br /&gt;
* Raises error on invalid question ID&lt;br /&gt;
&lt;br /&gt;
* Handles nil `@range_of_scores` cleanly&lt;br /&gt;
&lt;br /&gt;
* Supports custom score ranges like (1..3)&lt;br /&gt;
&lt;br /&gt;
* Ignores answers with scores outside the range&lt;br /&gt;
&lt;br /&gt;
* Ignores nil answers&lt;br /&gt;
&lt;br /&gt;
* Returns zeros when response maps exist but have no responses&lt;br /&gt;
&lt;br /&gt;
* Ignores unrelated questions and isolates correct question answers&lt;br /&gt;
&lt;br /&gt;
* Handles high-volume response datasets efficiently (tested with 50 responses)&lt;br /&gt;
&lt;br /&gt;
* Works reliably for all allowed response map types&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
* Accepts `Criterion`&lt;br /&gt;
* Accepts `Checkbox`&lt;br /&gt;
* Rejects non-statistical types like `TextArea`&lt;br /&gt;
* Rejects `nil` type&lt;br /&gt;
* Rejects empty string&lt;br /&gt;
* Rejects unknown types like `Dropdown`&lt;br /&gt;
* Accepts real instance of a valid question&lt;br /&gt;
* Case-sensitive check (`criterion` fails)&lt;br /&gt;
* Rejects non-string types (e.g., `:Criterion` symbol)&lt;br /&gt;
&lt;br /&gt;
= 📈 Final Outcomes =  &lt;br /&gt;
* 100% test coverage for helper module  &lt;br /&gt;
* Survey logic is now fully tested for correctness, completeness, and edge-case handling  &lt;br /&gt;
* SRP and DIP ensured for future-proofing  &lt;br /&gt;
* Tests are modular, clean, and isolated with repeatable results  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163611</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163611"/>
		<updated>2025-04-08T01:30:44Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Helper: SurveyDeploymentHelper */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates). While this functionality is important to the platform’s feedback loop, its code currently has minimal automated test coverage.  &lt;br /&gt;
Improving the test coverage of the &amp;lt;code&amp;gt;SurveyDeployment&amp;lt;/code&amp;gt; model and the associated &amp;lt;code&amp;gt;SurveyDeploymentHelper&amp;lt;/code&amp;gt; is critical for ensuring data integrity, proper user access, and time-based logic. The goal of this project is to define and implement unit tests that validate these behaviors thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Project Objectives ==  &lt;br /&gt;
Develop comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
&lt;br /&gt;
Ensure accurate testing of:&lt;br /&gt;
* Date/time validations  &lt;br /&gt;
* Survey type handling  &lt;br /&gt;
* Survey response aggregation  &lt;br /&gt;
* Question-type filtering  &lt;br /&gt;
&lt;br /&gt;
Other goals:&lt;br /&gt;
* Prepare a clean and extensible test foundation for future survey-related features  &lt;br /&gt;
* Increase test coverage from ~10% to a significantly higher level  &lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Core model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || To be created for testing helper logic  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Planned Testing Scenarios =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === &lt;br /&gt;
Each method in the SurveyDeployment model focuses on a single task. The valid_start_end_time? method encapsulates all date-related validation logic. Other methods like parent_name and response_maps are placeholders for implementation in child classes.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) === &lt;br /&gt;
The model is open for extension and closed for modification. By declaring methods like parent_name and response_maps, subclasses like AssignmentSurveyDeployment and CourseSurveyDeployment can provide specific implementations without changing the base class.&lt;br /&gt;
&lt;br /&gt;
=== Validation Logic === &lt;br /&gt;
Custom validation is implemented via the valid_start_end_time? method to ensure the consistency and logical correctness of start_date and end_date.&lt;br /&gt;
&lt;br /&gt;
=== Key Method to Test: valid_start_end_time? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
Ensures that:&lt;br /&gt;
&lt;br /&gt;
#start_date and end_date are both present.&lt;br /&gt;
#end_date occurs on or after start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'adds error when start_date and end_date are missing' do&lt;br /&gt;
  sd = SurveyDeployment.new&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The start and end time should be specified.')&lt;br /&gt;
end&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: end_date is before start_date'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'adds error when end_date is before start_date' do&lt;br /&gt;
  sd = SurveyDeployment.new(start_date: Time.now + 2.days, end_date: Time.now + 1.day)&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The End Date should be after the Start Date.')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: end_date is in the past'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'adds error when end_date is in the past' do&lt;br /&gt;
  sd = SurveyDeployment.new(start_date: Time.now - 5.days, end_date: Time.now - 1.day)&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The End Date should be in the future.')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Valid dates'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'is valid when start_date and end_date are logically correct' do&lt;br /&gt;
  sd = SurveyDeployment.new(start_date: Time.now + 1.day, end_date: Time.now + 5.days)&lt;br /&gt;
  expect(sd.valid?).to be true&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === &lt;br /&gt;
Each method handles a single responsibility:&lt;br /&gt;
&lt;br /&gt;
#get_responses_for_question_in_a_survey_deployment – aggregates survey responses.&lt;br /&gt;
#allowed_question_type? – validates allowed question types.&lt;br /&gt;
&lt;br /&gt;
=== Dependency Injection Principle (DIP) === &lt;br /&gt;
&lt;br /&gt;
These helper methods receive all necessary data as parameters, allowing for isolated testing.&lt;br /&gt;
&lt;br /&gt;
=== Method 1: get_responses_for_question_in_a_survey_deployment ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns a count of how many times each answer option (score) was selected for a given question, across all response maps of types:&lt;br /&gt;
&lt;br /&gt;
#AssignmentSurveyResponseMap&lt;br /&gt;
#CourseSurveyResponseMap&lt;br /&gt;
#GlobalSurveyResponseMap&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: Responses exist for each score'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'returns counts of answers for each score' do&lt;br /&gt;
  allow(Question).to receive(:find).and_return(question)&lt;br /&gt;
  allow(ResponseMap).to receive(:find_by_sql).and_return([response_map])&lt;br /&gt;
  allow(Response).to receive(:where).with(map_id: response_map.id).and_return([response])&lt;br /&gt;
  allow(Answer).to receive(:where).and_return(double(count: 3))&lt;br /&gt;
&lt;br /&gt;
  helper.instance_variable_set(:@range_of_scores, (1..5).to_a)&lt;br /&gt;
  counts = helper.get_responses_for_question_in_a_survey_deployment(question.id, survey_deployment.id)&lt;br /&gt;
&lt;br /&gt;
  expect(counts).to eq([3, 3, 3, 3, 3])&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: No responses found'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'returns zero counts when no answers exist' do&lt;br /&gt;
  allow(Question).to receive(:find).and_return(question)&lt;br /&gt;
  allow(ResponseMap).to receive(:find_by_sql).and_return([])&lt;br /&gt;
  helper.instance_variable_set(:@range_of_scores, (1..5).to_a)&lt;br /&gt;
&lt;br /&gt;
  counts = helper.get_responses_for_question_in_a_survey_deployment(question.id, survey_deployment.id)&lt;br /&gt;
  expect(counts).to eq([0, 0, 0, 0, 0])&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Method 2: allowed_question_type? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
&lt;br /&gt;
Returns true if the question type is either Criterion or Checkbox.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: Question type is Criterion'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'returns true for Criterion type' do&lt;br /&gt;
  question = double('Question', type: 'Criterion')&lt;br /&gt;
  expect(helper.allowed_question_type?(question)).to be true&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: Question type is Checkbox'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'returns true for Checkbox type' do&lt;br /&gt;
  question = double('Question', type: 'Checkbox')&lt;br /&gt;
  expect(helper.allowed_question_type?(question)).to be true&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: Question type is not allowed'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'returns false for other types' do&lt;br /&gt;
  question = double('Question', type: 'TextArea')&lt;br /&gt;
  expect(helper.allowed_question_type?(question)).to be false&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= 📈 Expected Outcomes =  &lt;br /&gt;
* Achieve &amp;gt;85% test coverage for both the model and helper  &lt;br /&gt;
* Validate critical functionality (date validation, response mapping, question filtering)  &lt;br /&gt;
* Lay a strong testing foundation for any future UI or logic changes related to surveys  &lt;br /&gt;
* Submit clean, modular, and maintainable RSpec tests  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163606</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163606"/>
		<updated>2025-04-08T01:26:52Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates). While this functionality is important to the platform’s feedback loop, its code currently has minimal automated test coverage.  &lt;br /&gt;
Improving the test coverage of the &amp;lt;code&amp;gt;SurveyDeployment&amp;lt;/code&amp;gt; model and the associated &amp;lt;code&amp;gt;SurveyDeploymentHelper&amp;lt;/code&amp;gt; is critical for ensuring data integrity, proper user access, and time-based logic. The goal of this project is to define and implement unit tests that validate these behaviors thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Project Objectives ==  &lt;br /&gt;
Develop comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
&lt;br /&gt;
Ensure accurate testing of:&lt;br /&gt;
* Date/time validations  &lt;br /&gt;
* Survey type handling  &lt;br /&gt;
* Survey response aggregation  &lt;br /&gt;
* Question-type filtering  &lt;br /&gt;
&lt;br /&gt;
Other goals:&lt;br /&gt;
* Prepare a clean and extensible test foundation for future survey-related features  &lt;br /&gt;
* Increase test coverage from ~10% to a significantly higher level  &lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Core model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || To be created for testing helper logic  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Planned Testing Scenarios =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === &lt;br /&gt;
Each method in the SurveyDeployment model focuses on a single task. The valid_start_end_time? method encapsulates all date-related validation logic. Other methods like parent_name and response_maps are placeholders for implementation in child classes.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) === &lt;br /&gt;
The model is open for extension and closed for modification. By declaring methods like parent_name and response_maps, subclasses like AssignmentSurveyDeployment and CourseSurveyDeployment can provide specific implementations without changing the base class.&lt;br /&gt;
&lt;br /&gt;
=== Validation Logic === &lt;br /&gt;
Custom validation is implemented via the valid_start_end_time? method to ensure the consistency and logical correctness of start_date and end_date.&lt;br /&gt;
&lt;br /&gt;
=== Key Method to Test: valid_start_end_time? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
Ensures that:&lt;br /&gt;
&lt;br /&gt;
#start_date and end_date are both present.&lt;br /&gt;
#end_date occurs on or after start_date.&lt;br /&gt;
#end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'adds error when start_date and end_date are missing' do&lt;br /&gt;
  sd = SurveyDeployment.new&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The start and end time should be specified.')&lt;br /&gt;
end&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: end_date is before start_date'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'adds error when end_date is before start_date' do&lt;br /&gt;
  sd = SurveyDeployment.new(start_date: Time.now + 2.days, end_date: Time.now + 1.day)&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The End Date should be after the Start Date.')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: end_date is in the past'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'adds error when end_date is in the past' do&lt;br /&gt;
  sd = SurveyDeployment.new(start_date: Time.now - 5.days, end_date: Time.now - 1.day)&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The End Date should be in the future.')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Valid dates'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'is valid when start_date and end_date are logically correct' do&lt;br /&gt;
  sd = SurveyDeployment.new(start_date: Time.now + 1.day, end_date: Time.now + 5.days)&lt;br /&gt;
  expect(sd.valid?).to be true&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
= 📈 Expected Outcomes =  &lt;br /&gt;
* Achieve &amp;gt;85% test coverage for both the model and helper  &lt;br /&gt;
* Validate critical functionality (date validation, response mapping, question filtering)  &lt;br /&gt;
* Lay a strong testing foundation for any future UI or logic changes related to surveys  &lt;br /&gt;
* Submit clean, modular, and maintainable RSpec tests  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163603</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163603"/>
		<updated>2025-04-08T01:26:41Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Test Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates). While this functionality is important to the platform’s feedback loop, its code currently has minimal automated test coverage.  &lt;br /&gt;
Improving the test coverage of the &amp;lt;code&amp;gt;SurveyDeployment&amp;lt;/code&amp;gt; model and the associated &amp;lt;code&amp;gt;SurveyDeploymentHelper&amp;lt;/code&amp;gt; is critical for ensuring data integrity, proper user access, and time-based logic. The goal of this project is to define and implement unit tests that validate these behaviors thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Project Objectives ==  &lt;br /&gt;
Develop comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
&lt;br /&gt;
Ensure accurate testing of:&lt;br /&gt;
* Date/time validations  &lt;br /&gt;
* Survey type handling  &lt;br /&gt;
* Survey response aggregation  &lt;br /&gt;
* Question-type filtering  &lt;br /&gt;
&lt;br /&gt;
Other goals:&lt;br /&gt;
* Prepare a clean and extensible test foundation for future survey-related features  &lt;br /&gt;
* Increase test coverage from ~10% to a significantly higher level  &lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Core model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || To be created for testing helper logic  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Planned Testing Scenarios =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === &lt;br /&gt;
Each method in the SurveyDeployment model focuses on a single task. The valid_start_end_time? method encapsulates all date-related validation logic. Other methods like parent_name and response_maps are placeholders for implementation in child classes.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) === &lt;br /&gt;
The model is open for extension and closed for modification. By declaring methods like parent_name and response_maps, subclasses like AssignmentSurveyDeployment and CourseSurveyDeployment can provide specific implementations without changing the base class.&lt;br /&gt;
&lt;br /&gt;
=== Validation Logic === &lt;br /&gt;
Custom validation is implemented via the valid_start_end_time? method to ensure the consistency and logical correctness of start_date and end_date.&lt;br /&gt;
&lt;br /&gt;
=== Key Method to Test: valid_start_end_time? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
Ensures that:&lt;br /&gt;
&lt;br /&gt;
start_date and end_date are both present.&lt;br /&gt;
&lt;br /&gt;
end_date occurs on or after start_date.&lt;br /&gt;
&lt;br /&gt;
end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'adds error when start_date and end_date are missing' do&lt;br /&gt;
  sd = SurveyDeployment.new&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The start and end time should be specified.')&lt;br /&gt;
end&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 2: end_date is before start_date'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'adds error when end_date is before start_date' do&lt;br /&gt;
  sd = SurveyDeployment.new(start_date: Time.now + 2.days, end_date: Time.now + 1.day)&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The End Date should be after the Start Date.')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 3: end_date is in the past'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'adds error when end_date is in the past' do&lt;br /&gt;
  sd = SurveyDeployment.new(start_date: Time.now - 5.days, end_date: Time.now - 1.day)&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The End Date should be in the future.')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Scenario 4: Valid dates'''&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'is valid when start_date and end_date are logically correct' do&lt;br /&gt;
  sd = SurveyDeployment.new(start_date: Time.now + 1.day, end_date: Time.now + 5.days)&lt;br /&gt;
  expect(sd.valid?).to be true&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
= 📈 Expected Outcomes =  &lt;br /&gt;
* Achieve &amp;gt;85% test coverage for both the model and helper  &lt;br /&gt;
* Validate critical functionality (date validation, response mapping, question filtering)  &lt;br /&gt;
* Lay a strong testing foundation for any future UI or logic changes related to surveys  &lt;br /&gt;
* Submit clean, modular, and maintainable RSpec tests  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163598</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163598"/>
		<updated>2025-04-08T01:25:39Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Test Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates). While this functionality is important to the platform’s feedback loop, its code currently has minimal automated test coverage.  &lt;br /&gt;
Improving the test coverage of the &amp;lt;code&amp;gt;SurveyDeployment&amp;lt;/code&amp;gt; model and the associated &amp;lt;code&amp;gt;SurveyDeploymentHelper&amp;lt;/code&amp;gt; is critical for ensuring data integrity, proper user access, and time-based logic. The goal of this project is to define and implement unit tests that validate these behaviors thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Project Objectives ==  &lt;br /&gt;
Develop comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
&lt;br /&gt;
Ensure accurate testing of:&lt;br /&gt;
* Date/time validations  &lt;br /&gt;
* Survey type handling  &lt;br /&gt;
* Survey response aggregation  &lt;br /&gt;
* Question-type filtering  &lt;br /&gt;
&lt;br /&gt;
Other goals:&lt;br /&gt;
* Prepare a clean and extensible test foundation for future survey-related features  &lt;br /&gt;
* Increase test coverage from ~10% to a significantly higher level  &lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Core model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || To be created for testing helper logic  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Planned Testing Scenarios =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === &lt;br /&gt;
Each method in the SurveyDeployment model focuses on a single task. The valid_start_end_time? method encapsulates all date-related validation logic. Other methods like parent_name and response_maps are placeholders for implementation in child classes.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) === &lt;br /&gt;
The model is open for extension and closed for modification. By declaring methods like parent_name and response_maps, subclasses like AssignmentSurveyDeployment and CourseSurveyDeployment can provide specific implementations without changing the base class.&lt;br /&gt;
&lt;br /&gt;
=== Validation Logic === &lt;br /&gt;
Custom validation is implemented via the valid_start_end_time? method to ensure the consistency and logical correctness of start_date and end_date.&lt;br /&gt;
&lt;br /&gt;
=== Key Method to Test: valid_start_end_time? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
Ensures that:&lt;br /&gt;
&lt;br /&gt;
start_date and end_date are both present.&lt;br /&gt;
&lt;br /&gt;
end_date occurs on or after start_date.&lt;br /&gt;
&lt;br /&gt;
end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;it 'adds error when start_date and end_date are missing' do&lt;br /&gt;
  sd = SurveyDeployment.new&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The start and end time should be specified.')&lt;br /&gt;
end&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
= 📈 Expected Outcomes =  &lt;br /&gt;
* Achieve &amp;gt;85% test coverage for both the model and helper  &lt;br /&gt;
* Validate critical functionality (date validation, response mapping, question filtering)  &lt;br /&gt;
* Lay a strong testing foundation for any future UI or logic changes related to surveys  &lt;br /&gt;
* Submit clean, modular, and maintainable RSpec tests  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163595</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163595"/>
		<updated>2025-04-08T01:25:03Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Test Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates). While this functionality is important to the platform’s feedback loop, its code currently has minimal automated test coverage.  &lt;br /&gt;
Improving the test coverage of the &amp;lt;code&amp;gt;SurveyDeployment&amp;lt;/code&amp;gt; model and the associated &amp;lt;code&amp;gt;SurveyDeploymentHelper&amp;lt;/code&amp;gt; is critical for ensuring data integrity, proper user access, and time-based logic. The goal of this project is to define and implement unit tests that validate these behaviors thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Project Objectives ==  &lt;br /&gt;
Develop comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
&lt;br /&gt;
Ensure accurate testing of:&lt;br /&gt;
* Date/time validations  &lt;br /&gt;
* Survey type handling  &lt;br /&gt;
* Survey response aggregation  &lt;br /&gt;
* Question-type filtering  &lt;br /&gt;
&lt;br /&gt;
Other goals:&lt;br /&gt;
* Prepare a clean and extensible test foundation for future survey-related features  &lt;br /&gt;
* Increase test coverage from ~10% to a significantly higher level  &lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Core model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || To be created for testing helper logic  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Planned Testing Scenarios =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === &lt;br /&gt;
Each method in the SurveyDeployment model focuses on a single task. The valid_start_end_time? method encapsulates all date-related validation logic. Other methods like parent_name and response_maps are placeholders for implementation in child classes.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) === &lt;br /&gt;
The model is open for extension and closed for modification. By declaring methods like parent_name and response_maps, subclasses like AssignmentSurveyDeployment and CourseSurveyDeployment can provide specific implementations without changing the base class.&lt;br /&gt;
&lt;br /&gt;
=== Validation Logic === &lt;br /&gt;
Custom validation is implemented via the valid_start_end_time? method to ensure the consistency and logical correctness of start_date and end_date.&lt;br /&gt;
&lt;br /&gt;
=== Key Method to Test: valid_start_end_time? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
Ensures that:&lt;br /&gt;
&lt;br /&gt;
start_date and end_date are both present.&lt;br /&gt;
&lt;br /&gt;
end_date occurs on or after start_date.&lt;br /&gt;
&lt;br /&gt;
end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;it 'adds error when start_date and end_date are missing' do&lt;br /&gt;
  sd = SurveyDeployment.new&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The start and end time should be specified.')&lt;br /&gt;
end&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
= 📈 Expected Outcomes =  &lt;br /&gt;
* Achieve &amp;gt;85% test coverage for both the model and helper  &lt;br /&gt;
* Validate critical functionality (date validation, response mapping, question filtering)  &lt;br /&gt;
* Lay a strong testing foundation for any future UI or logic changes related to surveys  &lt;br /&gt;
* Submit clean, modular, and maintainable RSpec tests  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163594</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163594"/>
		<updated>2025-04-08T01:24:43Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Test Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates). While this functionality is important to the platform’s feedback loop, its code currently has minimal automated test coverage.  &lt;br /&gt;
Improving the test coverage of the &amp;lt;code&amp;gt;SurveyDeployment&amp;lt;/code&amp;gt; model and the associated &amp;lt;code&amp;gt;SurveyDeploymentHelper&amp;lt;/code&amp;gt; is critical for ensuring data integrity, proper user access, and time-based logic. The goal of this project is to define and implement unit tests that validate these behaviors thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Project Objectives ==  &lt;br /&gt;
Develop comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
&lt;br /&gt;
Ensure accurate testing of:&lt;br /&gt;
* Date/time validations  &lt;br /&gt;
* Survey type handling  &lt;br /&gt;
* Survey response aggregation  &lt;br /&gt;
* Question-type filtering  &lt;br /&gt;
&lt;br /&gt;
Other goals:&lt;br /&gt;
* Prepare a clean and extensible test foundation for future survey-related features  &lt;br /&gt;
* Increase test coverage from ~10% to a significantly higher level  &lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Core model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || To be created for testing helper logic  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Planned Testing Scenarios =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === &lt;br /&gt;
Each method in the SurveyDeployment model focuses on a single task. The valid_start_end_time? method encapsulates all date-related validation logic. Other methods like parent_name and response_maps are placeholders for implementation in child classes.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) === &lt;br /&gt;
The model is open for extension and closed for modification. By declaring methods like parent_name and response_maps, subclasses like AssignmentSurveyDeployment and CourseSurveyDeployment can provide specific implementations without changing the base class.&lt;br /&gt;
&lt;br /&gt;
=== Validation Logic === &lt;br /&gt;
Custom validation is implemented via the valid_start_end_time? method to ensure the consistency and logical correctness of start_date and end_date.&lt;br /&gt;
&lt;br /&gt;
=== Key Method to Test: valid_start_end_time? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
Ensures that:&lt;br /&gt;
&lt;br /&gt;
start_date and end_date are both present.&lt;br /&gt;
&lt;br /&gt;
end_date occurs on or after start_date.&lt;br /&gt;
&lt;br /&gt;
end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: start_date and end_date are nil'''&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
it 'adds error when start_date and end_date are missing' do&lt;br /&gt;
  sd = SurveyDeployment.new&lt;br /&gt;
  sd.valid?&lt;br /&gt;
  expect(sd.errors[:base]).to include('The start and end time should be specified.')&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
= 📈 Expected Outcomes =  &lt;br /&gt;
* Achieve &amp;gt;85% test coverage for both the model and helper  &lt;br /&gt;
* Validate critical functionality (date validation, response mapping, question filtering)  &lt;br /&gt;
* Lay a strong testing foundation for any future UI or logic changes related to surveys  &lt;br /&gt;
* Submit clean, modular, and maintainable RSpec tests  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163593</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163593"/>
		<updated>2025-04-08T01:24:22Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* SurveyDeployment Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates). While this functionality is important to the platform’s feedback loop, its code currently has minimal automated test coverage.  &lt;br /&gt;
Improving the test coverage of the &amp;lt;code&amp;gt;SurveyDeployment&amp;lt;/code&amp;gt; model and the associated &amp;lt;code&amp;gt;SurveyDeploymentHelper&amp;lt;/code&amp;gt; is critical for ensuring data integrity, proper user access, and time-based logic. The goal of this project is to define and implement unit tests that validate these behaviors thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Project Objectives ==  &lt;br /&gt;
Develop comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
&lt;br /&gt;
Ensure accurate testing of:&lt;br /&gt;
* Date/time validations  &lt;br /&gt;
* Survey type handling  &lt;br /&gt;
* Survey response aggregation  &lt;br /&gt;
* Question-type filtering  &lt;br /&gt;
&lt;br /&gt;
Other goals:&lt;br /&gt;
* Prepare a clean and extensible test foundation for future survey-related features  &lt;br /&gt;
* Increase test coverage from ~10% to a significantly higher level  &lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Core model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || To be created for testing helper logic  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference&lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Planned Testing Scenarios =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === &lt;br /&gt;
Each method in the SurveyDeployment model focuses on a single task. The valid_start_end_time? method encapsulates all date-related validation logic. Other methods like parent_name and response_maps are placeholders for implementation in child classes.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) === &lt;br /&gt;
The model is open for extension and closed for modification. By declaring methods like parent_name and response_maps, subclasses like AssignmentSurveyDeployment and CourseSurveyDeployment can provide specific implementations without changing the base class.&lt;br /&gt;
&lt;br /&gt;
=== Validation Logic === &lt;br /&gt;
Custom validation is implemented via the valid_start_end_time? method to ensure the consistency and logical correctness of start_date and end_date.&lt;br /&gt;
&lt;br /&gt;
=== Key Method to Test: valid_start_end_time? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
Ensures that:&lt;br /&gt;
&lt;br /&gt;
start_date and end_date are both present.&lt;br /&gt;
&lt;br /&gt;
end_date occurs on or after start_date.&lt;br /&gt;
&lt;br /&gt;
end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
= 📈 Expected Outcomes =  &lt;br /&gt;
* Achieve &amp;gt;85% test coverage for both the model and helper  &lt;br /&gt;
* Validate critical functionality (date validation, response mapping, question filtering)  &lt;br /&gt;
* Lay a strong testing foundation for any future UI or logic changes related to surveys  &lt;br /&gt;
* Submit clean, modular, and maintainable RSpec tests  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163592</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163592"/>
		<updated>2025-04-08T01:24:11Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Key Method to Test: valid_start_end_time? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates). While this functionality is important to the platform’s feedback loop, its code currently has minimal automated test coverage.  &lt;br /&gt;
Improving the test coverage of the &amp;lt;code&amp;gt;SurveyDeployment&amp;lt;/code&amp;gt; model and the associated &amp;lt;code&amp;gt;SurveyDeploymentHelper&amp;lt;/code&amp;gt; is critical for ensuring data integrity, proper user access, and time-based logic. The goal of this project is to define and implement unit tests that validate these behaviors thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Project Objectives ==  &lt;br /&gt;
Develop comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
&lt;br /&gt;
Ensure accurate testing of:&lt;br /&gt;
* Date/time validations  &lt;br /&gt;
* Survey type handling  &lt;br /&gt;
* Survey response aggregation  &lt;br /&gt;
* Question-type filtering  &lt;br /&gt;
&lt;br /&gt;
Other goals:&lt;br /&gt;
* Prepare a clean and extensible test foundation for future survey-related features  &lt;br /&gt;
* Increase test coverage from ~10% to a significantly higher level  &lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Core model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || To be created for testing helper logic  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference  &lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Planned Testing Scenarios =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === &lt;br /&gt;
Each method in the SurveyDeployment model focuses on a single task. The valid_start_end_time? method encapsulates all date-related validation logic. Other methods like parent_name and response_maps are placeholders for implementation in child classes.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) === &lt;br /&gt;
The model is open for extension and closed for modification. By declaring methods like parent_name and response_maps, subclasses like AssignmentSurveyDeployment and CourseSurveyDeployment can provide specific implementations without changing the base class.&lt;br /&gt;
&lt;br /&gt;
=== Validation Logic === &lt;br /&gt;
Custom validation is implemented via the valid_start_end_time? method to ensure the consistency and logical correctness of start_date and end_date.&lt;br /&gt;
&lt;br /&gt;
=== Key Method to Test: valid_start_end_time? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== &lt;br /&gt;
Ensures that:&lt;br /&gt;
&lt;br /&gt;
start_date and end_date are both present.&lt;br /&gt;
&lt;br /&gt;
end_date occurs on or after start_date.&lt;br /&gt;
&lt;br /&gt;
end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
= 📈 Expected Outcomes =  &lt;br /&gt;
* Achieve &amp;gt;85% test coverage for both the model and helper  &lt;br /&gt;
* Validate critical functionality (date validation, response mapping, question filtering)  &lt;br /&gt;
* Lay a strong testing foundation for any future UI or logic changes related to surveys  &lt;br /&gt;
* Submit clean, modular, and maintainable RSpec tests  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163591</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163591"/>
		<updated>2025-04-08T01:23:59Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Model: SurveyDeployment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates). While this functionality is important to the platform’s feedback loop, its code currently has minimal automated test coverage.  &lt;br /&gt;
Improving the test coverage of the &amp;lt;code&amp;gt;SurveyDeployment&amp;lt;/code&amp;gt; model and the associated &amp;lt;code&amp;gt;SurveyDeploymentHelper&amp;lt;/code&amp;gt; is critical for ensuring data integrity, proper user access, and time-based logic. The goal of this project is to define and implement unit tests that validate these behaviors thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Project Objectives ==  &lt;br /&gt;
Develop comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
&lt;br /&gt;
Ensure accurate testing of:&lt;br /&gt;
* Date/time validations  &lt;br /&gt;
* Survey type handling  &lt;br /&gt;
* Survey response aggregation  &lt;br /&gt;
* Question-type filtering  &lt;br /&gt;
&lt;br /&gt;
Other goals:&lt;br /&gt;
* Prepare a clean and extensible test foundation for future survey-related features  &lt;br /&gt;
* Increase test coverage from ~10% to a significantly higher level  &lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Core model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || To be created for testing helper logic  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference  &lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Planned Testing Scenarios =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === &lt;br /&gt;
Each method in the SurveyDeployment model focuses on a single task. The valid_start_end_time? method encapsulates all date-related validation logic. Other methods like parent_name and response_maps are placeholders for implementation in child classes.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) === &lt;br /&gt;
The model is open for extension and closed for modification. By declaring methods like parent_name and response_maps, subclasses like AssignmentSurveyDeployment and CourseSurveyDeployment can provide specific implementations without changing the base class.&lt;br /&gt;
&lt;br /&gt;
=== Validation Logic === &lt;br /&gt;
Custom validation is implemented via the valid_start_end_time? method to ensure the consistency and logical correctness of start_date and end_date.&lt;br /&gt;
&lt;br /&gt;
=== Key Method to Test: valid_start_end_time? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== Ensures that:&lt;br /&gt;
&lt;br /&gt;
start_date and end_date are both present.&lt;br /&gt;
&lt;br /&gt;
end_date occurs on or after start_date.&lt;br /&gt;
&lt;br /&gt;
end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
= 📈 Expected Outcomes =  &lt;br /&gt;
* Achieve &amp;gt;85% test coverage for both the model and helper  &lt;br /&gt;
* Validate critical functionality (date validation, response mapping, question filtering)  &lt;br /&gt;
* Lay a strong testing foundation for any future UI or logic changes related to surveys  &lt;br /&gt;
* Submit clean, modular, and maintainable RSpec tests  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163590</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163590"/>
		<updated>2025-04-08T01:23:38Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* 🔍 Planned Testing Scenarios */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= 📘 Project Overview =&lt;br /&gt;
&lt;br /&gt;
== Problem Statement ==  &lt;br /&gt;
The SurveyDeployment feature in Expertiza is responsible for deploying surveys that collect feedback from students across different scopes: assignments, courses, and globally. Each survey is tied to a questionnaire and operates within a scheduled time window (start and end dates). While this functionality is important to the platform’s feedback loop, its code currently has minimal automated test coverage.  &lt;br /&gt;
Improving the test coverage of the &amp;lt;code&amp;gt;SurveyDeployment&amp;lt;/code&amp;gt; model and the associated &amp;lt;code&amp;gt;SurveyDeploymentHelper&amp;lt;/code&amp;gt; is critical for ensuring data integrity, proper user access, and time-based logic. The goal of this project is to define and implement unit tests that validate these behaviors thoroughly.&lt;br /&gt;
&lt;br /&gt;
== Project Objectives ==  &lt;br /&gt;
Develop comprehensive RSpec test cases for:&lt;br /&gt;
* SurveyDeployment model  &lt;br /&gt;
* SurveyDeploymentHelper module  &lt;br /&gt;
&lt;br /&gt;
Ensure accurate testing of:&lt;br /&gt;
* Date/time validations  &lt;br /&gt;
* Survey type handling  &lt;br /&gt;
* Survey response aggregation  &lt;br /&gt;
* Question-type filtering  &lt;br /&gt;
&lt;br /&gt;
Other goals:&lt;br /&gt;
* Prepare a clean and extensible test foundation for future survey-related features  &lt;br /&gt;
* Increase test coverage from ~10% to a significantly higher level  &lt;br /&gt;
&lt;br /&gt;
== Files Involved ==  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! File Path !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/models/survey_deployment.rb&amp;lt;/code&amp;gt; || Core model for managing survey deployment lifecycle  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;app/helpers/survey_deployment_helper.rb&amp;lt;/code&amp;gt; || Helper methods for aggregating and filtering survey-related data  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/models/survey_deployment_spec.rb&amp;lt;/code&amp;gt; || To be expanded for model validations and polymorphic behavior  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spec/helpers/survey_deployment_helper_spec.rb&amp;lt;/code&amp;gt; || To be created for testing helper logic  &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Mentor ==&lt;br /&gt;
&lt;br /&gt;
* Mitesh Anil Agarwal&lt;br /&gt;
&lt;br /&gt;
== Team Members ==&lt;br /&gt;
&lt;br /&gt;
* Vibhav Deo&lt;br /&gt;
* Marmik Patel&lt;br /&gt;
* Harsh Vora&lt;br /&gt;
&lt;br /&gt;
= 📂 Class and Method Overview =&lt;br /&gt;
&lt;br /&gt;
== SurveyDeployment Model == &lt;br /&gt;
This model ensures that surveys are deployed with valid time intervals and are associated with a questionnaire. It also acts as a parent class to specific types of surveys like &amp;lt;code&amp;gt;AssignmentSurveyDeployment&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;CourseSurveyDeployment&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* '''Key Method:''' &amp;lt;code&amp;gt;valid_start_end_time?&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Checks that both &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; are present  &lt;br /&gt;
** Ensures &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is after or equal to &amp;lt;code&amp;gt;start_date&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Requires that &amp;lt;code&amp;gt;end_date&amp;lt;/code&amp;gt; is in the future  &lt;br /&gt;
&lt;br /&gt;
* '''Polymorphic Methods (to be tested):'''  &lt;br /&gt;
** &amp;lt;code&amp;gt;response_maps&amp;lt;/code&amp;gt;: Returns response maps associated with a specific deployment (delegated to subclasses)  &lt;br /&gt;
** &amp;lt;code&amp;gt;parent_name&amp;lt;/code&amp;gt;: Abstract placeholder for future UI reference  &lt;br /&gt;
&lt;br /&gt;
== SurveyDeploymentHelper Module ==  &lt;br /&gt;
This module contains utility methods that support survey response aggregation and question filtering.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;get_responses_for_question_in_a_survey_deployment(q_id, sd_id)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Collects responses to a question across multiple survey types (Assignment, Course, Global)  &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;allowed_question_type?(question)&amp;lt;/code&amp;gt;  &lt;br /&gt;
** Returns true for allowed types (&amp;lt;code&amp;gt;Criterion&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;Checkbox&amp;lt;/code&amp;gt;)  &lt;br /&gt;
** Used to filter questions eligible for statistical reporting  &lt;br /&gt;
&lt;br /&gt;
= 🔍 Planned Testing Scenarios =&lt;br /&gt;
&lt;br /&gt;
== Model: SurveyDeployment ==&lt;br /&gt;
&lt;br /&gt;
=== Single Responsibility Principle (SRP) === Each method in the SurveyDeployment model focuses on a single task. The valid_start_end_time? method encapsulates all date-related validation logic. Other methods like parent_name and response_maps are placeholders for implementation in child classes.&lt;br /&gt;
&lt;br /&gt;
=== Open/Closed Principle (OCP) === The model is open for extension and closed for modification. By declaring methods like parent_name and response_maps, subclasses like AssignmentSurveyDeployment and CourseSurveyDeployment can provide specific implementations without changing the base class.&lt;br /&gt;
&lt;br /&gt;
=== Validation Logic === Custom validation is implemented via the valid_start_end_time? method to ensure the consistency and logical correctness of start_date and end_date.&lt;br /&gt;
&lt;br /&gt;
=== Key Method to Test: valid_start_end_time? ===&lt;br /&gt;
&lt;br /&gt;
==== Description ==== Ensures that:&lt;br /&gt;
&lt;br /&gt;
start_date and end_date are both present.&lt;br /&gt;
&lt;br /&gt;
end_date occurs on or after start_date.&lt;br /&gt;
&lt;br /&gt;
end_date is in the future.&lt;br /&gt;
&lt;br /&gt;
==== Test Scenarios ====&lt;br /&gt;
&lt;br /&gt;
'''Scenario 1: start_date and end_date are nil'''&lt;br /&gt;
&lt;br /&gt;
== Helper: SurveyDeploymentHelper ==&lt;br /&gt;
&lt;br /&gt;
= 📈 Expected Outcomes =  &lt;br /&gt;
* Achieve &amp;gt;85% test coverage for both the model and helper  &lt;br /&gt;
* Validate critical functionality (date validation, response mapping, question filtering)  &lt;br /&gt;
* Lay a strong testing foundation for any future UI or logic changes related to surveys  &lt;br /&gt;
* Submit clean, modular, and maintainable RSpec tests  &lt;br /&gt;
&lt;br /&gt;
= 🔗 References =  &lt;br /&gt;
* [https://github.com/expertiza/expertiza Expertiza GitHub Repository]  &lt;br /&gt;
* [http://expertiza.ncsu.edu/ Expertiza Wiki Documentation]  &lt;br /&gt;
* [https://rspec.info/documentation/ RSpec Docs]  &lt;br /&gt;
* [https://guides.rubyonrails.org/testing.html Rails Testing Guide]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163448</id>
		<title>CSC/ECE 517 Spring 2025 - E2528 Testing for Survey Deployment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2528_Testing_for_Survey_Deployment&amp;diff=163448"/>
		<updated>2025-04-07T22:08:18Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: 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>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025&amp;diff=163412</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=163412"/>
		<updated>2025-04-07T18:57:50Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* 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;
* [[CSC/ECE 517 Spring 2025 - E2527. Mentor-meeting management: assignments with topics]]&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;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=162400</id>
		<title>CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=162400"/>
		<updated>2025-03-24T21:45:20Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* answer_tags_controller_spec.rb */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2505. Testing - Answer Tagging==&lt;br /&gt;
&lt;br /&gt;
This wiki page is for the description of changes made in Spring 2025, CSC/ECE 517 for the E2505 Testing - Testing Answer Tagging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
In accordance with the [http://rubyonrails.org/ Ruby on Rails] framework, [http://expertiza.ncsu.edu/ Expertiza] is an open source software project (OSS) led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Through this platform, the instructor can add and edit assignments that students are able to view and contribute to. There are various filtering methods that streamline this process. There is also the ability for students to peer review other students to give contributing feedback.&lt;br /&gt;
&lt;br /&gt;
==Objective==&lt;br /&gt;
Our objective is to test two files which are part of this process. We are testing a controller for answer tags which is responsible for fetching, creating, editing and deleting answer tags for a given assignment, questionnaire and user. As well as a model for tag prompt deployment which interfaces with this answer tags controller which has methods that return various information about a students progress in tagging answers.&lt;br /&gt;
&lt;br /&gt;
==Controller and Spec Files==&lt;br /&gt;
Answer Tags&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/answer_tags_controller.rb answer_tags_controller.rb] with initial coverage of 0%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Tag Prompt Deployment&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/tag_prompts_controller.rb tag_prompt_deployment.rb] with initial coverage of 17.65%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing Implementation==&lt;br /&gt;
===Answer Tags Controller===&lt;br /&gt;
This controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/controllers/answer_tags_controller.rb] creates/edits answer tags and tracks the number of tags a student has completed overall per assignment or questionnaire. The controller filters based on assignment_id, questionnaire_id and user_id to present appropriate records. The controllers' output is a JSON-formatted collection of response tags. &lt;br /&gt;
&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''action_allowed?'' : Determines whether the current user is permitted to access the given action (index or create_edit) based on their role.&lt;br /&gt;
&lt;br /&gt;
: Use Cases: &lt;br /&gt;
&lt;br /&gt;
:: - When it is a student session, access to index should be allowed.&lt;br /&gt;
:: - When it is a student session, access to create_edit should be allowed.&lt;br /&gt;
:: - When the session user is a student, access to unsupported actions like destroy or show should be denied.&lt;br /&gt;
:: - When the session user is a **teaching assistant**, access to `index` should be allowed.&lt;br /&gt;
:: - When the session user is a **teaching assistant**, access to `create_edit` should be allowed.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
&lt;br /&gt;
:: - When the session is not defined, access to any action (e.g., index, create_edit) should be denied.&lt;br /&gt;
:: - When a user with no role assigned tries to access index or create_edit, access should be denied.&lt;br /&gt;
:: - When an Instructor tries to access an unsupported action (e.g., destroy), access should be denied.&lt;br /&gt;
:: - When the action parameter is missing or unrecognized, access should be denied regardless of user role.&lt;br /&gt;
&lt;br /&gt;
''index'' : Returns all the tag prompt deployments in JSON format&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: * For any authenticated user above student access:&lt;br /&gt;
:: - When anyone above student privilege is authorized&lt;br /&gt;
:: - When there are no tag prompts deployed, a empty list should be displayed.&lt;br /&gt;
:: - When there is 1 tag prompt deployed, 1 should be displayed.&lt;br /&gt;
:: - When there are tag prompts deployed with no associated assignment answer tag, tag prompts should not be displayed.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, it should be filtered by an user_id.&lt;br /&gt;
:: - When there is an answer tag associated with an assignment_id, it should be filtered by an assignment_id.&lt;br /&gt;
:: - When there is an answer tag associated with a questionnaire_id, it should be filtered by a questionnaire_id.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, assignment_id, and questionnaire_id, it should be filtered by a user_id, assignment_id, questionnaire_id.&lt;br /&gt;
:: - When there is no answer tag associated with a assignment_id, no tag prompts are returned for a assignment_id with no associated answer tags.&lt;br /&gt;
:: - When there is no answer tag associated with a questionnaire_id, no tag prompts are returned for a questionnaire_id with no associated answer tags.&lt;br /&gt;
:: - When provided with both assignment_id and questionnaire_id, it should provide the correct filtered response.&lt;br /&gt;
:: - When provided with one incorrect and one correct param, then no records should be returned.&lt;br /&gt;
: * When there are multiple tags are present for an assignment, all related tags should be returned.&lt;br /&gt;
: * When a user request is made, it should return records related to current user only.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
&lt;br /&gt;
: * When user_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When assignment_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When questionnaire_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When an unauthorized user tries to access the #index, the user should be returned to root_page.&lt;br /&gt;
: * When an invalid parameter is passed, the system should not break and should return valid results.&lt;br /&gt;
: * When there are large number of answer tags, the tags are handled properly.&lt;br /&gt;
&lt;br /&gt;
''create_edit'' : Allows the creation or updating of an answer tag for the current student.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
:: - When a valid combination of answer_id, tag_prompt_deployment_id, and value is provided by a student and no existing tag exists, a new AnswerTag is created.&lt;br /&gt;
:: - When a student accesses an existing tag, the tag is updated with the new provided value.&lt;br /&gt;
:: - When a student provides a user_id in the parameters, the controller still uses the current_user to ensure tags are associated only with the logged-in student.&lt;br /&gt;
:: - When create_edit is called multiple times with the same parameters, it does not create duplicate AnswerTag records — the existing one is updated.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
:: - When no answer_id is provided, the system raises an error and does not create or update the tag.&lt;br /&gt;
:: - When no tag_prompt_deployment_id is provided, the system raises an error.&lt;br /&gt;
:: - When no value is provided, the tag creation/update is rejected with an error.&lt;br /&gt;
:: - When incorrect or unexpected user_id is passed, it is ignored, and the tag is created for the current_user.&lt;br /&gt;
&lt;br /&gt;
===Tag Prompt Deployment Controller===&lt;br /&gt;
The controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/models/tag_prompt_deployment.rb] is used by an instructor to view the tagging summary of the users that completed the answer tagging. It also indicates that comments are to be tagged for the characteristic specified by the tag prompt.&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''tag_prompt'' : Tests that the tag prompt associated with the provided tag_prompt_id is correctly returned by the tag_dep.tag_prompt method.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When given a valid tag_prompt_id, it should return the associated tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
: * When given an invalid tag_prompt_id, it should not return a tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
''get_number_of_taggable_answers'' : Calculates total taggable answers assigned for a user who participated in ``tag review assignment.''&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When user_id is nil, it should return an error message.&lt;br /&gt;
: * When answer_length_threshold is null, it should return a count of tangible answers.&lt;br /&gt;
: * When answer_length_threshold is not null, it should return a count of taggable answers less than answers_one.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When there are no responses, it should return zero as the count of taggable answers.&lt;br /&gt;
: * When questions are empty, it should return count of taggable answers as zero.&lt;br /&gt;
&lt;br /&gt;
''assignment_tagging_progress'' : Accesses the percentage progress of answer tagging.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do not vary by round, it should calculate the tagging progress for each user.&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do vary by round, it should calculate the tagging progress for each user considering all tagged items.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no questions are found, it should return an empty list.&lt;br /&gt;
: * When there are no teams or questions, it should return an empty list.&lt;br /&gt;
&lt;br /&gt;
==Testing Details==&lt;br /&gt;
====Demo Videos====&lt;br /&gt;
# [https://drive.google.com/file/d/1UTeJC7oc8pbWZeOuCZt3JcdfW5uDv3Fu/view?usp=drive_link Demo Video for Tag Prompt Deployment Controller]&lt;br /&gt;
# [https://drive.google.com/file/d/1dJjeqZxuDon11R12YUp6UVXHD846Ogdz/view?usp=drive_link Demo Video for Answer Tags Controller]&lt;br /&gt;
&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb] and [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb].&lt;br /&gt;
&lt;br /&gt;
=====How to See Test Coverage=====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====answer_tags_controller_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 63.2&lt;br /&gt;
&lt;br /&gt;
[[File:Answer_tags_controller_coverage_2505.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
====tag_prompt_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 5.2&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
1. Modify base files&lt;br /&gt;
   a. correct several method names (ex: not named after a verb (assignment_tagging_progress))&lt;br /&gt;
   b. make tag_prompt_deployment.rb more readable and better commented&lt;br /&gt;
   c. Break some methods down into smaller ones for better functionality (assignment_tagging_progress)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
# [https://github.com/Michael-Anderson-NCSU/expertiza Project Repository]&lt;br /&gt;
# [https://github.com/expertiza/expertiza/pull/2936 Pull Request]&lt;br /&gt;
# [https://www.theodinproject.com/lessons/ruby-introduction-to-rspec RSpec]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=162399</id>
		<title>CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=162399"/>
		<updated>2025-03-24T21:45:01Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Testing Details */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2505. Testing - Answer Tagging==&lt;br /&gt;
&lt;br /&gt;
This wiki page is for the description of changes made in Spring 2025, CSC/ECE 517 for the E2505 Testing - Testing Answer Tagging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
In accordance with the [http://rubyonrails.org/ Ruby on Rails] framework, [http://expertiza.ncsu.edu/ Expertiza] is an open source software project (OSS) led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Through this platform, the instructor can add and edit assignments that students are able to view and contribute to. There are various filtering methods that streamline this process. There is also the ability for students to peer review other students to give contributing feedback.&lt;br /&gt;
&lt;br /&gt;
==Objective==&lt;br /&gt;
Our objective is to test two files which are part of this process. We are testing a controller for answer tags which is responsible for fetching, creating, editing and deleting answer tags for a given assignment, questionnaire and user. As well as a model for tag prompt deployment which interfaces with this answer tags controller which has methods that return various information about a students progress in tagging answers.&lt;br /&gt;
&lt;br /&gt;
==Controller and Spec Files==&lt;br /&gt;
Answer Tags&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/answer_tags_controller.rb answer_tags_controller.rb] with initial coverage of 0%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Tag Prompt Deployment&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/tag_prompts_controller.rb tag_prompt_deployment.rb] with initial coverage of 17.65%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing Implementation==&lt;br /&gt;
===Answer Tags Controller===&lt;br /&gt;
This controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/controllers/answer_tags_controller.rb] creates/edits answer tags and tracks the number of tags a student has completed overall per assignment or questionnaire. The controller filters based on assignment_id, questionnaire_id and user_id to present appropriate records. The controllers' output is a JSON-formatted collection of response tags. &lt;br /&gt;
&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''action_allowed?'' : Determines whether the current user is permitted to access the given action (index or create_edit) based on their role.&lt;br /&gt;
&lt;br /&gt;
: Use Cases: &lt;br /&gt;
&lt;br /&gt;
:: - When it is a student session, access to index should be allowed.&lt;br /&gt;
:: - When it is a student session, access to create_edit should be allowed.&lt;br /&gt;
:: - When the session user is a student, access to unsupported actions like destroy or show should be denied.&lt;br /&gt;
:: - When the session user is a **teaching assistant**, access to `index` should be allowed.&lt;br /&gt;
:: - When the session user is a **teaching assistant**, access to `create_edit` should be allowed.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
&lt;br /&gt;
:: - When the session is not defined, access to any action (e.g., index, create_edit) should be denied.&lt;br /&gt;
:: - When a user with no role assigned tries to access index or create_edit, access should be denied.&lt;br /&gt;
:: - When an Instructor tries to access an unsupported action (e.g., destroy), access should be denied.&lt;br /&gt;
:: - When the action parameter is missing or unrecognized, access should be denied regardless of user role.&lt;br /&gt;
&lt;br /&gt;
''index'' : Returns all the tag prompt deployments in JSON format&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: * For any authenticated user above student access:&lt;br /&gt;
:: - When anyone above student privilege is authorized&lt;br /&gt;
:: - When there are no tag prompts deployed, a empty list should be displayed.&lt;br /&gt;
:: - When there is 1 tag prompt deployed, 1 should be displayed.&lt;br /&gt;
:: - When there are tag prompts deployed with no associated assignment answer tag, tag prompts should not be displayed.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, it should be filtered by an user_id.&lt;br /&gt;
:: - When there is an answer tag associated with an assignment_id, it should be filtered by an assignment_id.&lt;br /&gt;
:: - When there is an answer tag associated with a questionnaire_id, it should be filtered by a questionnaire_id.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, assignment_id, and questionnaire_id, it should be filtered by a user_id, assignment_id, questionnaire_id.&lt;br /&gt;
:: - When there is no answer tag associated with a assignment_id, no tag prompts are returned for a assignment_id with no associated answer tags.&lt;br /&gt;
:: - When there is no answer tag associated with a questionnaire_id, no tag prompts are returned for a questionnaire_id with no associated answer tags.&lt;br /&gt;
:: - When provided with both assignment_id and questionnaire_id, it should provide the correct filtered response.&lt;br /&gt;
:: - When provided with one incorrect and one correct param, then no records should be returned.&lt;br /&gt;
: * When there are multiple tags are present for an assignment, all related tags should be returned.&lt;br /&gt;
: * When a user request is made, it should return records related to current user only.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
&lt;br /&gt;
: * When user_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When assignment_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When questionnaire_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When an unauthorized user tries to access the #index, the user should be returned to root_page.&lt;br /&gt;
: * When an invalid parameter is passed, the system should not break and should return valid results.&lt;br /&gt;
: * When there are large number of answer tags, the tags are handled properly.&lt;br /&gt;
&lt;br /&gt;
''create_edit'' : Allows the creation or updating of an answer tag for the current student.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
:: - When a valid combination of answer_id, tag_prompt_deployment_id, and value is provided by a student and no existing tag exists, a new AnswerTag is created.&lt;br /&gt;
:: - When a student accesses an existing tag, the tag is updated with the new provided value.&lt;br /&gt;
:: - When a student provides a user_id in the parameters, the controller still uses the current_user to ensure tags are associated only with the logged-in student.&lt;br /&gt;
:: - When create_edit is called multiple times with the same parameters, it does not create duplicate AnswerTag records — the existing one is updated.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
:: - When no answer_id is provided, the system raises an error and does not create or update the tag.&lt;br /&gt;
:: - When no tag_prompt_deployment_id is provided, the system raises an error.&lt;br /&gt;
:: - When no value is provided, the tag creation/update is rejected with an error.&lt;br /&gt;
:: - When incorrect or unexpected user_id is passed, it is ignored, and the tag is created for the current_user.&lt;br /&gt;
&lt;br /&gt;
===Tag Prompt Deployment Controller===&lt;br /&gt;
The controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/models/tag_prompt_deployment.rb] is used by an instructor to view the tagging summary of the users that completed the answer tagging. It also indicates that comments are to be tagged for the characteristic specified by the tag prompt.&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''tag_prompt'' : Tests that the tag prompt associated with the provided tag_prompt_id is correctly returned by the tag_dep.tag_prompt method.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When given a valid tag_prompt_id, it should return the associated tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
: * When given an invalid tag_prompt_id, it should not return a tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
''get_number_of_taggable_answers'' : Calculates total taggable answers assigned for a user who participated in ``tag review assignment.''&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When user_id is nil, it should return an error message.&lt;br /&gt;
: * When answer_length_threshold is null, it should return a count of tangible answers.&lt;br /&gt;
: * When answer_length_threshold is not null, it should return a count of taggable answers less than answers_one.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When there are no responses, it should return zero as the count of taggable answers.&lt;br /&gt;
: * When questions are empty, it should return count of taggable answers as zero.&lt;br /&gt;
&lt;br /&gt;
''assignment_tagging_progress'' : Accesses the percentage progress of answer tagging.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do not vary by round, it should calculate the tagging progress for each user.&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do vary by round, it should calculate the tagging progress for each user considering all tagged items.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no questions are found, it should return an empty list.&lt;br /&gt;
: * When there are no teams or questions, it should return an empty list.&lt;br /&gt;
&lt;br /&gt;
==Testing Details==&lt;br /&gt;
====Demo Videos====&lt;br /&gt;
# [https://drive.google.com/file/d/1UTeJC7oc8pbWZeOuCZt3JcdfW5uDv3Fu/view?usp=drive_link Demo Video for Tag Prompt Deployment Controller]&lt;br /&gt;
# [https://drive.google.com/file/d/1dJjeqZxuDon11R12YUp6UVXHD846Ogdz/view?usp=drive_link Demo Video for Answer Tags Controller]&lt;br /&gt;
&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb] and [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb].&lt;br /&gt;
&lt;br /&gt;
=====How to See Test Coverage=====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====answer_tags_controller_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 63.1&lt;br /&gt;
&lt;br /&gt;
[[File:Answer_tags_controller_coverage_2505.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
====tag_prompt_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 5.2&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
1. Modify base files&lt;br /&gt;
   a. correct several method names (ex: not named after a verb (assignment_tagging_progress))&lt;br /&gt;
   b. make tag_prompt_deployment.rb more readable and better commented&lt;br /&gt;
   c. Break some methods down into smaller ones for better functionality (assignment_tagging_progress)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
# [https://github.com/Michael-Anderson-NCSU/expertiza Project Repository]&lt;br /&gt;
# [https://github.com/expertiza/expertiza/pull/2936 Pull Request]&lt;br /&gt;
# [https://www.theodinproject.com/lessons/ruby-introduction-to-rspec RSpec]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=162320</id>
		<title>CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=162320"/>
		<updated>2025-03-24T18:00:54Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: /* Objective */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2505. Testing - Answer Tagging==&lt;br /&gt;
&lt;br /&gt;
This wiki page is for the description of changes made in Spring 2025, CSC/ECE 517 for the E2505 Testing - Testing Answer Tagging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
In accordance with the [http://rubyonrails.org/ Ruby on Rails] framework, [http://expertiza.ncsu.edu/ Expertiza] is an open source software project (OSS) led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Through this platform, the instructor can add and edit assignments that students are able to view and contribute to. There are various filtering methods that streamline this process. There is also the ability for students to peer review other students to give contributing feedback.&lt;br /&gt;
&lt;br /&gt;
==Objective==&lt;br /&gt;
Our objective is to test two files which are part of this process. We are testing a controller for answer tags which is responsible for fetching, creating, editing and deleting answer tags for a given assignment, questionnaire and user. As well as a model for tag prompt deployment which interfaces with this answer tags controller which has methods that return various information about a students progress in tagging answers.&lt;br /&gt;
&lt;br /&gt;
==Controller and Spec Files==&lt;br /&gt;
Answer Tags&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/answer_tags_controller.rb answer_tags_controller.rb] with initial coverage of 0%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Tag Prompt Deployment&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/tag_prompts_controller.rb tag_prompt_deployment.rb] with initial coverage of 17.65%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing Implementation==&lt;br /&gt;
===Answer Tags Controller===&lt;br /&gt;
This controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/controllers/answer_tags_controller.rb] creates/edits answer tags and tracks the number of tags a student has completed overall per assignment or questionnaire. The controller filters based on assignment_id, questionnaire_id and user_id to present appropriate records. The controllers' output is a JSON-formatted collection of response tags. &lt;br /&gt;
&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''action_allowed?'' : Determines whether the current user is permitted to access the given action (index or create_edit) based on their role.&lt;br /&gt;
&lt;br /&gt;
: Use Cases: &lt;br /&gt;
&lt;br /&gt;
:: - When it is a student session, access to index should be allowed.&lt;br /&gt;
:: - When it is a student session, access to create_edit should be allowed.&lt;br /&gt;
:: - When the session user is a student, access to unsupported actions like destroy or show should be denied.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
&lt;br /&gt;
:: - When the session is not defined, access to any action (e.g., index, create_edit) should be denied.&lt;br /&gt;
:: - When a user with no role assigned tries to access index or create_edit, access should be denied.&lt;br /&gt;
:: - When an Instructor tries to access an unsupported action (e.g., destroy), access should be denied.&lt;br /&gt;
:: - When the action parameter is missing or unrecognized, access should be denied regardless of user role.&lt;br /&gt;
&lt;br /&gt;
''index'' : Returns all the tag prompt deployments in JSON format&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: * For any authenticated user above student access:&lt;br /&gt;
:: - When anyone above student privilege is authorized&lt;br /&gt;
:: - When there are no tag prompts deployed, a empty list should be displayed.&lt;br /&gt;
:: - When there is 1 tag prompt deployed, 1 should be displayed.&lt;br /&gt;
:: - When there are tag prompts deployed with no associated assignment answer tag, tag prompts should not be displayed.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, it should be filtered by an user_id.&lt;br /&gt;
:: - When there is an answer tag associated with an assignment_id, it should be filtered by an assignment_id.&lt;br /&gt;
:: - When there is an answer tag associated with a questionnaire_id, it should be filtered by a questionnaire_id.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, assignment_id, and questionnaire_id, it should be filtered by a user_id, assignment_id, questionnaire_id.&lt;br /&gt;
:: - When there is no answer tag associated with a assignment_id, no tag prompts are returned for a assignment_id with no associated answer tags.&lt;br /&gt;
:: - When there is no answer tag associated with a questionnaire_id, no tag prompts are returned for a questionnaire_id with no associated answer tags.&lt;br /&gt;
:: - When provided with both assignment_id and questionnaire_id, it should provide the correct filtered response.&lt;br /&gt;
:: - When provided with one incorrect and one correct param, then no records should be returned.&lt;br /&gt;
: * When there are multiple tags are present for an assignment, all related tags should be returned.&lt;br /&gt;
: * When a user request is made, it should return records related to current user only.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
&lt;br /&gt;
: * When user_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When assignment_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When questionnaire_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When an unauthorized user tries to access the #index, the user should be returned to root_page.&lt;br /&gt;
: * When an invalid parameter is passed, the system should not break and should return valid results.&lt;br /&gt;
: * When there are large number of answer tags, the tags are handled properly.&lt;br /&gt;
&lt;br /&gt;
''create_edit'' : Allows the creation or updating of an answer tag for the current student.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
:: - When a valid combination of answer_id, tag_prompt_deployment_id, and value is provided by a student and no existing tag exists, a new AnswerTag is created.&lt;br /&gt;
:: - When a student accesses an existing tag, the tag is updated with the new provided value.&lt;br /&gt;
:: - When a student provides a user_id in the parameters, the controller still uses the current_user to ensure tags are associated only with the logged-in student.&lt;br /&gt;
:: - When create_edit is called multiple times with the same parameters, it does not create duplicate AnswerTag records — the existing one is updated.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
:: - When no answer_id is provided, the system raises an error and does not create or update the tag.&lt;br /&gt;
:: - When no tag_prompt_deployment_id is provided, the system raises an error.&lt;br /&gt;
:: - When no value is provided, the tag creation/update is rejected with an error.&lt;br /&gt;
:: - When incorrect or unexpected user_id is passed, it is ignored, and the tag is created for the current_user.&lt;br /&gt;
&lt;br /&gt;
===Tag Prompt Deployment Controller===&lt;br /&gt;
The controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/models/tag_prompt_deployment.rb] is used by an instructor to view the tagging summary of the users that completed the answer tagging. It also indicates that comments are to be tagged for the characteristic specified by the tag prompt.&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''tag_prompt'' : Tests that the tag prompt associated with the provided tag_prompt_id is correctly returned by the tag_dep.tag_prompt method.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When given a valid tag_prompt_id, it should return the associated tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
: * When given an invalid tag_prompt_id, it should not return a tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
''get_number_of_taggable_answers'' : Calculates total taggable answers assigned for a user who participated in ``tag review assignment.''&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When user_id is nil, it should return an error message.&lt;br /&gt;
: * When answer_length_threshold is null, it should return a count of tangible answers.&lt;br /&gt;
: * When answer_length_threshold is not null, it should return a count of taggable answers less than answers_one.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When there are no responses, it should return zero as the count of taggable answers.&lt;br /&gt;
: * When questions are empty, it should return count of taggable answers as zero.&lt;br /&gt;
&lt;br /&gt;
''assignment_tagging_progress'' : Accesses the percentage progress of answer tagging.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do not vary by round, it should calculate the tagging progress for each user.&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do vary by round, it should calculate the tagging progress for each user considering all tagged items.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no questions are found, it should return an empty list.&lt;br /&gt;
: * When there are no teams or questions, it should return an empty list.&lt;br /&gt;
&lt;br /&gt;
==Testing Details==&lt;br /&gt;
====Demo Videos====&lt;br /&gt;
# [https://drive.google.com/file/d/1UTeJC7oc8pbWZeOuCZt3JcdfW5uDv3Fu/view?usp=drive_link Demo Video for Tag Prompt Deployment Controller]&lt;br /&gt;
&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb] and [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb].&lt;br /&gt;
&lt;br /&gt;
=====How to See Test Coverage=====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====answer_tags_controller_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 63.1&lt;br /&gt;
&lt;br /&gt;
[[File:Answer_tags_controller_coverage_2505.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
====tag_prompt_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 5.2&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png|1000px]]&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
1. Modify base files&lt;br /&gt;
   a. correct several method names (ex: not named after a verb (assignment_tagging_progress))&lt;br /&gt;
   b. make tag_prompt_deployment.rb more readable and better commented&lt;br /&gt;
   c. Break some methods down into smaller ones for better functionality (assignment_tagging_progress)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
# [https://github.com/Michael-Anderson-NCSU/expertiza Project Repository]&lt;br /&gt;
# [https://github.com/expertiza/expertiza/pull/2936 Pull Request]&lt;br /&gt;
# [https://www.theodinproject.com/lessons/ruby-introduction-to-rspec RSpec]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=161774</id>
		<title>CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=161774"/>
		<updated>2025-03-23T04:54:00Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2413. Testing - Answer Tagging==&lt;br /&gt;
&lt;br /&gt;
This wiki page is for the description of changes made in Spring 2025, CSC/ECE 517 for the E2505 Testing - Testing Answer Tagging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
In accordance with the [http://rubyonrails.org/ Ruby on Rails] framework, [http://expertiza.ncsu.edu/ Expertiza] is an open source software project (OSS) led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Through this platform, the instructor can add and edit assignments that students are able to view and contribute to. There are various filtering methods that streamline this process. There is also the ability for students to peer review other students to give contributing feedback.&lt;br /&gt;
&lt;br /&gt;
==Objective==&lt;br /&gt;
Our objective is to test two files which are part of this process. We are testing a controller for answer tags DESCRIBE ANSWER TAGS HERE EDIT ME. As well as a model for tag prompt deployment which interfaces with this answer tags controller which has methods that return various information about a students progress in tagging answers.&lt;br /&gt;
&lt;br /&gt;
==Controller and Spec Files==&lt;br /&gt;
Answer Tags&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/answer_tags_controller.rb answer_tags_controller.rb] with initial coverage of 0%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Tag Prompt Deployment&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/tag_prompts_controller.rb tag_prompt_deployment.rb] with initial coverage of 17.65%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing Implementation==&lt;br /&gt;
===Answer Tags Controller===&lt;br /&gt;
This controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/controllers/answer_tags_controller.rb] creates/edits answer tags and tracks the number of tags a student has completed overall per assignment or questionnaire. The controller filters based on assignment_id, questionnaire_id and user_id to present appropriate records. The controllers' output is a JSON-formatted collection of response tags. &lt;br /&gt;
&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''action_allowed?'' : Determines whether the current user is permitted to access the given action (index or create_edit) based on their role.&lt;br /&gt;
&lt;br /&gt;
: Use Cases: &lt;br /&gt;
&lt;br /&gt;
:: - When it is a student session, access to index should be allowed.&lt;br /&gt;
:: - When it is a student session, access to create_edit should be allowed.&lt;br /&gt;
:: - When the session user is a student, access to unsupported actions like destroy or show should be denied.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
&lt;br /&gt;
:: - When the session is not defined, access to any action (e.g., index, create_edit) should be denied.&lt;br /&gt;
:: - When a user with no role assigned tries to access index or create_edit, access should be denied.&lt;br /&gt;
:: - When an Instructor tries to access an unsupported action (e.g., destroy), access should be denied.&lt;br /&gt;
:: - When the action parameter is missing or unrecognized, access should be denied regardless of user role.&lt;br /&gt;
&lt;br /&gt;
''index'' : Returns all the tag prompt deployments in JSON format&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: * For any authenticated user above student access:&lt;br /&gt;
:: - When anyone above student privilege is authorized&lt;br /&gt;
:: - When there are no tag prompts deployed, a empty list should be displayed.&lt;br /&gt;
:: - When there is 1 tag prompt deployed, 1 should be displayed.&lt;br /&gt;
:: - When there are tag prompts deployed with no associated assignment answer tag, tag prompts should not be displayed.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, it should be filtered by an user_id.&lt;br /&gt;
:: - When there is an answer tag associated with an assignment_id, it should be filtered by an assignment_id.&lt;br /&gt;
:: - When there is an answer tag associated with a questionnaire_id, it should be filtered by a questionnaire_id.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, assignment_id, and questionnaire_id, it should be filtered by a user_id, assignment_id, questionnaire_id.&lt;br /&gt;
:: - When there is no answer tag associated with a assignment_id, no tag prompts are returned for a assignment_id with no associated answer tags.&lt;br /&gt;
:: - When there is no answer tag associated with a questionnaire_id, no tag prompts are returned for a questionnaire_id with no associated answer tags.&lt;br /&gt;
:: - When provided with both assignment_id and questionnaire_id, it should provide the correct filtered response.&lt;br /&gt;
:: - When provided with one incorrect and one correct param, then no records should be returned.&lt;br /&gt;
: * When there are multiple tags are present for an assignment, all related tags should be returned.&lt;br /&gt;
: * When a user request is made, it should return records related to current user only.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
&lt;br /&gt;
: * When user_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When assignment_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When questionnaire_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When an unauthorized user tries to access the #index, the user should be returned to root_page.&lt;br /&gt;
: * When an invalid parameter is passed, the system should not break and should return valid results.&lt;br /&gt;
: * When there are large number of answer tags, the tags are handled properly.&lt;br /&gt;
&lt;br /&gt;
''create_edit'' : Allows the creation or updating of an answer tag for the current student.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
:: - When a valid combination of answer_id, tag_prompt_deployment_id, and value is provided by a student and no existing tag exists, a new AnswerTag is created.&lt;br /&gt;
:: - When a student accesses an existing tag, the tag is updated with the new provided value.&lt;br /&gt;
:: - When a student provides a user_id in the parameters, the controller still uses the current_user to ensure tags are associated only with the logged-in student.&lt;br /&gt;
:: - When create_edit is called multiple times with the same parameters, it does not create duplicate AnswerTag records — the existing one is updated.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
:: - When no answer_id is provided, the system raises an error and does not create or update the tag.&lt;br /&gt;
:: - When no tag_prompt_deployment_id is provided, the system raises an error.&lt;br /&gt;
:: - When no value is provided, the tag creation/update is rejected with an error.&lt;br /&gt;
:: - When incorrect or unexpected user_id is passed, it is ignored, and the tag is created for the current_user.&lt;br /&gt;
&lt;br /&gt;
===Tag Prompt Deployment Controller===&lt;br /&gt;
The controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/models/tag_prompt_deployment.rb] is used by an instructor to view the tagging summary of the users that completed the answer tagging. It also indicates that comments are to be tagged for the characteristic specified by the tag prompt.&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''tag_prompt'' : Tests that the tag prompt associated with the provided tag_prompt_id is correctly returned by the tag_dep.tag_prompt method.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When given a valid tag_prompt_id, it should return the associated tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
: * When given an invalid tag_prompt_id, it should not return a tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
''get_number_of_taggable_answers'' : Calculates total taggable answers assigned for a user who participated in ``tag review assignment.''&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When user_id is nil, it should return an error message.&lt;br /&gt;
: * When answer_length_threshold is null, it should return a count of tangible answers.&lt;br /&gt;
: * When answer_length_threshold is not null, it should return a count of taggable answers less than answers_one.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When there are no responses, it should return zero as the count of taggable answers.&lt;br /&gt;
: * When questions are empty, it should return count of taggable answers as zero.&lt;br /&gt;
&lt;br /&gt;
''assignment_tagging_progress'' : Accesses the percentage progress of answer tagging.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do not vary by round, it should calculate the tagging progress for each user.&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do vary by round, it should calculate the tagging progress for each user considering all tagged items.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no questions are found, it should return an empty list.&lt;br /&gt;
: * When there are no teams or questions, it should return an empty list.&lt;br /&gt;
&lt;br /&gt;
==Testing Details==&lt;br /&gt;
====Demo Videos====&lt;br /&gt;
put demo video here&lt;br /&gt;
&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb] and [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb].&lt;br /&gt;
&lt;br /&gt;
=====How to See Test Coverage=====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
====answer_tags_controller_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 63.1&lt;br /&gt;
&lt;br /&gt;
[[File:Answer_tags_controller_coverage_2505.png]]&lt;br /&gt;
&lt;br /&gt;
====tag_prompt_deployment_spec.rb====&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 5.2&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png]]&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
1. Modify base files&lt;br /&gt;
   a. correct several method names (ex: not named after a verb (assignment_tagging_progress))&lt;br /&gt;
   b. make tag_prompt_deployment.rb more readable and better commented&lt;br /&gt;
   c. Break some methods down into smaller ones for better functionality (assignment_tagging_progress)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
# [https://github.com/CSC517-Project3/expertiza Project Repository]&lt;br /&gt;
# [https://github.com/orgs/CSC517-Project3/projects/1/views/1 Github Project Board]&lt;br /&gt;
# [https://github.com/expertiza/expertiza/pull/2775 Pull Request]&lt;br /&gt;
# [https://www.theodinproject.com/lessons/ruby-introduction-to-rspec RSpec]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=161773</id>
		<title>CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=161773"/>
		<updated>2025-03-23T04:52:34Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2413. Testing - Answer Tagging==&lt;br /&gt;
&lt;br /&gt;
This wiki page is for the description of changes made in Spring 2025, CSC/ECE 517 for the E2505 Testing - Testing Answer Tagging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
In accordance with the [http://rubyonrails.org/ Ruby on Rails] framework, [http://expertiza.ncsu.edu/ Expertiza] is an open source software project (OSS) led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Through this platform, the instructor can add and edit assignments that students are able to view and contribute to. There are various filtering methods that streamline this process. There is also the ability for students to peer review other students to give contributing feedback.&lt;br /&gt;
&lt;br /&gt;
==Objective==&lt;br /&gt;
Our objective is to test two files which are part of this process. We are testing a controller for answer tags DESCRIBE ANSWER TAGS HERE EDIT ME. As well as a model for tag prompt deployment which interfaces with this answer tags controller which has methods that return various information about a students progress in tagging answers.&lt;br /&gt;
&lt;br /&gt;
==Controller and Spec Files==&lt;br /&gt;
Answer Tags&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/answer_tags_controller.rb answer_tags_controller.rb] with initial coverage of 0%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Tag Prompt Deployment&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/tag_prompts_controller.rb tag_prompt_deployment.rb] with initial coverage of 17.65%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing Implementation==&lt;br /&gt;
===Answer Tags Controller===&lt;br /&gt;
This controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/controllers/answer_tags_controller.rb] creates/edits answer tags and tracks the number of tags a student has completed overall per assignment or questionnaire. The controller filters based on assignment_id, questionnaire_id and user_id to present appropriate records. The controllers' output is a JSON-formatted collection of response tags. &lt;br /&gt;
&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''action_allowed?'' : Determines whether the current user is permitted to access the given action (index or create_edit) based on their role.&lt;br /&gt;
&lt;br /&gt;
: Use Cases: &lt;br /&gt;
&lt;br /&gt;
:: - When it is a student session, access to index should be allowed.&lt;br /&gt;
:: - When it is a student session, access to create_edit should be allowed.&lt;br /&gt;
:: - When the session user is a student, access to unsupported actions like destroy or show should be denied.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
&lt;br /&gt;
:: - When the session is not defined, access to any action (e.g., index, create_edit) should be denied.&lt;br /&gt;
:: - When a user with no role assigned tries to access index or create_edit, access should be denied.&lt;br /&gt;
:: - When an Instructor tries to access an unsupported action (e.g., destroy), access should be denied.&lt;br /&gt;
:: - When the action parameter is missing or unrecognized, access should be denied regardless of user role.&lt;br /&gt;
&lt;br /&gt;
''index'' : Returns all the tag prompt deployments in JSON format&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: * For any authenticated user above student access:&lt;br /&gt;
:: - When anyone above student privilege is authorized&lt;br /&gt;
:: - When there are no tag prompts deployed, a empty list should be displayed.&lt;br /&gt;
:: - When there is 1 tag prompt deployed, 1 should be displayed.&lt;br /&gt;
:: - When there are tag prompts deployed with no associated assignment answer tag, tag prompts should not be displayed.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, it should be filtered by an user_id.&lt;br /&gt;
:: - When there is an answer tag associated with an assignment_id, it should be filtered by an assignment_id.&lt;br /&gt;
:: - When there is an answer tag associated with a questionnaire_id, it should be filtered by a questionnaire_id.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, assignment_id, and questionnaire_id, it should be filtered by a user_id, assignment_id, questionnaire_id.&lt;br /&gt;
:: - When there is no answer tag associated with a assignment_id, no tag prompts are returned for a assignment_id with no associated answer tags.&lt;br /&gt;
:: - When there is no answer tag associated with a questionnaire_id, no tag prompts are returned for a questionnaire_id with no associated answer tags.&lt;br /&gt;
:: - When provided with both assignment_id and questionnaire_id, it should provide the correct filtered response.&lt;br /&gt;
:: - When provided with one incorrect and one correct param, then no records should be returned.&lt;br /&gt;
: * When there are multiple tags are present for an assignment, all related tags should be returned.&lt;br /&gt;
: * When a user request is made, it should return records related to current user only.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
&lt;br /&gt;
: * When user_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When assignment_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When questionnaire_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When an unauthorized user tries to access the #index, the user should be returned to root_page.&lt;br /&gt;
: * When an invalid parameter is passed, the system should not break and should return valid results.&lt;br /&gt;
: * When there are large number of answer tags, the tags are handled properly.&lt;br /&gt;
&lt;br /&gt;
''create_edit'' : Allows the creation or updating of an answer tag for the current student.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
:: - When a valid combination of answer_id, tag_prompt_deployment_id, and value is provided by a student and no existing tag exists, a new AnswerTag is created.&lt;br /&gt;
:: - When a student accesses an existing tag, the tag is updated with the new provided value.&lt;br /&gt;
:: - When a student provides a user_id in the parameters, the controller still uses the current_user to ensure tags are associated only with the logged-in student.&lt;br /&gt;
:: - When create_edit is called multiple times with the same parameters, it does not create duplicate AnswerTag records — the existing one is updated.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
:: - When no answer_id is provided, the system raises an error and does not create or update the tag.&lt;br /&gt;
:: - When no tag_prompt_deployment_id is provided, the system raises an error.&lt;br /&gt;
:: - When no value is provided, the tag creation/update is rejected with an error.&lt;br /&gt;
:: - When incorrect or unexpected user_id is passed, it is ignored, and the tag is created for the current_user.&lt;br /&gt;
&lt;br /&gt;
===Tag Prompt Deployment Controller===&lt;br /&gt;
The controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/models/tag_prompt_deployment.rb] is used by an instructor to view the tagging summary of the users that completed the answer tagging. It also indicates that comments are to be tagged for the characteristic specified by the tag prompt.&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''tag_prompt'' : Tests that the tag prompt associated with the provided tag_prompt_id is correctly returned by the tag_dep.tag_prompt method.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When given a valid tag_prompt_id, it should return the associated tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
: * When given an invalid tag_prompt_id, it should not return a tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
''get_number_of_taggable_answers'' : Calculates total taggable answers assigned for a user who participated in ``tag review assignment.''&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When user_id is nil, it should return an error message.&lt;br /&gt;
: * When answer_length_threshold is null, it should return a count of tangible answers.&lt;br /&gt;
: * When answer_length_threshold is not null, it should return a count of taggable answers less than answers_one.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When there are no responses, it should return zero as the count of taggable answers.&lt;br /&gt;
: * When questions are empty, it should return count of taggable answers as zero.&lt;br /&gt;
&lt;br /&gt;
''assignment_tagging_progress'' : Accesses the percentage progress of answer tagging.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do not vary by round, it should calculate the tagging progress for each user.&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do vary by round, it should calculate the tagging progress for each user considering all tagged items.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no questions are found, it should return an empty list.&lt;br /&gt;
: * When there are no teams or questions, it should return an empty list.&lt;br /&gt;
&lt;br /&gt;
==Testing Details==&lt;br /&gt;
====Demo Videos====&lt;br /&gt;
put demo video here&lt;br /&gt;
&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb] and [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb].&lt;br /&gt;
&lt;br /&gt;
=====How to See Test Coverage=====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
### answer_tags_controller_spec.rb&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 63.1&lt;br /&gt;
&lt;br /&gt;
[[File:Answer_tags_controller_coverage_2505.png]]&lt;br /&gt;
&lt;br /&gt;
### tag_prompt_deployment_spec.rb&lt;br /&gt;
&lt;br /&gt;
: Coverage: 100%&lt;br /&gt;
: Hits/line: 5.2&lt;br /&gt;
&lt;br /&gt;
[[File:Tag_prompt_deployment_coverage_2025.png]]&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
1. Modify base files&lt;br /&gt;
   a. correct several method names (ex: not named after a verb (assignment_tagging_progress))&lt;br /&gt;
   b. make tag_prompt_deployment.rb more readable and better commented&lt;br /&gt;
   c. Break some methods down into smaller ones for better functionality (assignment_tagging_progress)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
# [https://github.com/CSC517-Project3/expertiza Project Repository]&lt;br /&gt;
# [https://github.com/orgs/CSC517-Project3/projects/1/views/1 Github Project Board]&lt;br /&gt;
# [https://github.com/expertiza/expertiza/pull/2775 Pull Request]&lt;br /&gt;
# [https://www.theodinproject.com/lessons/ruby-introduction-to-rspec RSpec]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Tag_prompt_deployment_coverage_2025.png&amp;diff=161772</id>
		<title>File:Tag prompt deployment coverage 2025.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Tag_prompt_deployment_coverage_2025.png&amp;diff=161772"/>
		<updated>2025-03-23T04:52:19Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: Coverage of tag_prompt_deployment_spec.rb&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Coverage of tag_prompt_deployment_spec.rb&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:Answer_tags_controller_coverage_2505.png&amp;diff=161769</id>
		<title>File:Answer tags controller coverage 2505.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:Answer_tags_controller_coverage_2505.png&amp;diff=161769"/>
		<updated>2025-03-23T04:44:48Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: Coverage result of answer_tags_controller_spec.rb&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Summary ==&lt;br /&gt;
Coverage result of answer_tags_controller_spec.rb&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=161566</id>
		<title>CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=161566"/>
		<updated>2025-03-22T23:29:08Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2413. Testing - Answer Tagging==&lt;br /&gt;
&lt;br /&gt;
This wiki page is for the description of changes made in Spring 2025, CSC/ECE 517 for the E2505 Testing - Testing Answer Tagging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
In accordance with the [http://rubyonrails.org/ Ruby on Rails] framework, [http://expertiza.ncsu.edu/ Expertiza] is an open source software project (OSS) led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Through this platform, the instructor can add and edit assignments that students are able to view and contribute to. There are various filtering methods that streamline this process. There is also the ability for students to peer review other students to give contributing feedback.&lt;br /&gt;
&lt;br /&gt;
==Objective==&lt;br /&gt;
Our objective is to test two files which are part of this process. We are testing a controller for answer tags DESCRIBE ANSWER TAGS HERE EDIT ME. As well as a model for tag prompt deployment which interfaces with this answer tags controller which has methods that return various information about a students progress in tagging answers.&lt;br /&gt;
&lt;br /&gt;
==Controller and Spec Files==&lt;br /&gt;
Answer Tags&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/answer_tags_controller.rb answer_tags_controller.rb] with initial coverage of 0%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Tag Prompt Deployment&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/tag_prompts_controller.rb tag_prompt_deployment.rb] with initial coverage of 17.65%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing Implementation==&lt;br /&gt;
===Answer Tags Controller===&lt;br /&gt;
This controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/controllers/answer_tags_controller.rb] creates/edits answer tags and tracks the number of tags a student has completed overall per assignment or questionnaire. The controller filters based on assignment_id, questionnaire_id and user_id to present appropriate records. The controllers' output is a JSON-formatted collection of response tags. &lt;br /&gt;
&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''action_allowed?'' : Determines if the user has the permission to see all the tags or create_edit a tag.&lt;br /&gt;
&lt;br /&gt;
: Use Cases: &lt;br /&gt;
&lt;br /&gt;
: * When it is a student session, access to index should be allowed.&lt;br /&gt;
: * When it is a student session, access to create_edit should be allowed.&lt;br /&gt;
: * When it is a student session, access to destroy should not be allowed.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
&lt;br /&gt;
: * When the session is undefined, access to index should be inaccessible.&lt;br /&gt;
: * When the session is undefined, access to create_edit should be inaccessible.&lt;br /&gt;
: * When the session is undefined, access to destroy should be inaccessible.&lt;br /&gt;
&lt;br /&gt;
''index'' : Returns all the tag prompt deployments in JSON format&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: * For any authenticated user above student access:&lt;br /&gt;
:: - When anyone above student privilege is authorized&lt;br /&gt;
:: - When there are no tag prompts deployed, a empty list should be displayed.&lt;br /&gt;
:: - When there is 1 tag prompt deployed, 1 should be displayed.&lt;br /&gt;
:: - When there are tag prompts deployed with no associated assignment answer tag, tag prompts should not be displayed.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, it should be filtered by an user_id.&lt;br /&gt;
:: - When there is an answer tag associated with an assignment_id, it should be filtered by an assignment_id.&lt;br /&gt;
:: - When there is an answer tag associated with a questionnaire_id, it should be filtered by a questionnaire_id.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, assignment_id, and questionnaire_id, it should be filtered by a user_id, assignment_id, questionnaire_id.&lt;br /&gt;
:: - When there is no answer tag associated with a assignment_id, no tag prompts are returned for a assignment_id with no associated answer tags.&lt;br /&gt;
:: - When there is no answer tag associated with a questionnaire_id, no tag prompts are returned for a questionnaire_id with no associated answer tags.&lt;br /&gt;
:: - When provided with both assignment_id and questionnaire_id, it should provide the correct filtered response.&lt;br /&gt;
:: - When provided with one incorrect and one correct param, then no records should be returned.&lt;br /&gt;
: * When there are multiple tags are present for an assignment, all related tags should be returned.&lt;br /&gt;
: * When a user request is made, it should return records related to current user only.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
&lt;br /&gt;
: * When user_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When assignment_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When questionnaire_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When an unauthorized user tries to access the #index, the user should be returned to root_page.&lt;br /&gt;
: * When an invalid parameter is passed, the system should not break and should return valid results.&lt;br /&gt;
: * When there are large number of answer tags, the tags are handled properly.&lt;br /&gt;
&lt;br /&gt;
''create_edit'' : Allow the creation or updating of an answer tag.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: * When a current tag is accessed, the current tag should be updated with new provided values.&lt;br /&gt;
: * When a current tag is accessed by a student, the current tag should not be updated with new values.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no mapping is found related to any tag_prompt_deployment for that tag (foreign key constraint), an empty list of tags prompts should be returned.&lt;br /&gt;
&lt;br /&gt;
===Tag Prompt Deployment Controller===&lt;br /&gt;
The controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/models/tag_prompt_deployment.rb] is used by an instructor to view the tagging summary of the users that completed the answer tagging. It also indicates that comments are to be tagged for the characteristic specified by the tag prompt.&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''tag_prompt'' : Tests that the tag prompt associated with the provided tag_prompt_id is correctly returned by the tag_dep.tag_prompt method.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When given a valid tag_prompt_id, it should return the associated tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
: * When given an invalid tag_prompt_id, it should not return a tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
''get_number_of_taggable_answers'' : Calculates total taggable answers assigned for a user who participated in ``tag review assignment.''&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When user_id is nil, it should return an error message.&lt;br /&gt;
: * When answer_length_threshold is null, it should return a count of tangible answers.&lt;br /&gt;
: * When answer_length_threshold is not null, it should return a count of taggable answers less than answers_one.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When there are no responses, it should return zero as the count of taggable answers.&lt;br /&gt;
: * When questions are empty, it should return count of taggable answers as zero.&lt;br /&gt;
&lt;br /&gt;
''assignment_tagging_progress'' : Accesses the percentage progress of answer tagging.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do not vary by round, it should calculate the tagging progress for each user.&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do vary by round, it should calculate the tagging progress for each user considering all tagged items.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no questions are found, it should return an empty list.&lt;br /&gt;
: * When there are no teams or questions, it should return an empty list.&lt;br /&gt;
&lt;br /&gt;
==Testing Details==&lt;br /&gt;
====Demo Videos====&lt;br /&gt;
put demo video here&lt;br /&gt;
&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb] and [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb].&lt;br /&gt;
&lt;br /&gt;
=====How to See Test Coverage=====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
1. Modify base files&lt;br /&gt;
   a. correct several method names (ex: not named after a verb (assignment_tagging_progress))&lt;br /&gt;
   b. make tag_prompt_deployment.rb more readable and better commented&lt;br /&gt;
   c. Break some methods down into smaller ones for better functionality (assignment_tagging_progress)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
# [https://github.com/CSC517-Project3/expertiza Project Repository]&lt;br /&gt;
# [https://github.com/orgs/CSC517-Project3/projects/1/views/1 Github Project Board]&lt;br /&gt;
# [https://github.com/expertiza/expertiza/pull/2775 Pull Request]&lt;br /&gt;
# [https://www.theodinproject.com/lessons/ruby-introduction-to-rspec RSpec]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=161564</id>
		<title>CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=161564"/>
		<updated>2025-03-22T23:28:26Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2413. Testing - Answer Tagging==&lt;br /&gt;
&lt;br /&gt;
This wiki page is for the description of changes made in Spring 2025, CSC/ECE 517 for the E2505 Testing - Testing Answer Tagging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
In accordance with the [http://rubyonrails.org/ Ruby on Rails] framework, [http://expertiza.ncsu.edu/ Expertiza] is an open source software project (OSS) led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Through this platform, the instructor can add and edit assignments that students are able to view and contribute to. There are various filtering methods that streamline this process. There is also the ability for students to peer review other students to give contributing feedback.&lt;br /&gt;
&lt;br /&gt;
==Objective==&lt;br /&gt;
Our objective is to test two files which are part of this process. We are testing a controller for answer tags DESCRIBE ANSWER TAGS HERE EDIT ME. As well as a model for tag prompt deployment which interfaces with this answer tags controller which has methods that return various information about a students progress in tagging answers.&lt;br /&gt;
&lt;br /&gt;
==Controller and Spec Files==&lt;br /&gt;
Answer Tags&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/answer_tags_controller.rb answer_tags_controller.rb] with initial coverage of 0%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Tag Prompt Deployment&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/tag_prompts_controller.rb tag_prompt_deployment.rb] with initial coverage of 17.65%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing Implementation==&lt;br /&gt;
===Answer Tags Controller===&lt;br /&gt;
This controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/controllers/answer_tags_controller.rb] creates/edits answer tags and tracks the number of tags a student has completed overall per assignment or questionnaire. The controller filters based on assignment_id, questionnaire_id and user_id to present appropriate records. The controllers' output is a JSON-formatted collection of response tags. &lt;br /&gt;
&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''action_allowed?'' : Determines if the user has the permission to see all the tags or create_edit a tag.&lt;br /&gt;
&lt;br /&gt;
: Use Cases: &lt;br /&gt;
&lt;br /&gt;
: * When it is a student session, access to index should be allowed.&lt;br /&gt;
: * When it is a student session, access to create_edit should be allowed.&lt;br /&gt;
: * When it is a student session, access to destroy should not be allowed.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
&lt;br /&gt;
: * When the session is undefined, access to index should be inaccessible.&lt;br /&gt;
: * When the session is undefined, access to create_edit should be inaccessible.&lt;br /&gt;
: * When the session is undefined, access to destroy should be inaccessible.&lt;br /&gt;
&lt;br /&gt;
''index'' : Returns all the tag prompt deployments in JSON format&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: * For any authenticated user above student access:&lt;br /&gt;
:: - When anyone above student privilege is authorized&lt;br /&gt;
:: - When there are no tag prompts deployed, a empty list should be displayed.&lt;br /&gt;
:: - When there is 1 tag prompt deployed, 1 should be displayed.&lt;br /&gt;
:: - When there are tag prompts deployed with no associated assignment answer tag, tag prompts should not be displayed.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, it should be filtered by an user_id.&lt;br /&gt;
:: - When there is an answer tag associated with an assignment_id, it should be filtered by an assignment_id.&lt;br /&gt;
:: - When there is an answer tag associated with a questionnaire_id, it should be filtered by a questionnaire_id.&lt;br /&gt;
:: - When there is an answer tag associated with an user_id, assignment_id, and questionnaire_id, it should be filtered by a user_id, assignment_id, questionnaire_id.&lt;br /&gt;
:: - When there is no answer tag associated with a assignment_id, no tag prompts are returned for a assignment_id with no associated answer tags.&lt;br /&gt;
:: - When there is no answer tag associated with a questionnaire_id, no tag prompts are returned for a questionnaire_id with no associated answer tags.&lt;br /&gt;
:: - When provided with both assignment_id and questionnaire_id, it should provide the correct filtered response.&lt;br /&gt;
:: - When provided with one incorrect and one correct param, then no records should be returned.&lt;br /&gt;
: * When there are multiple tags are present for an assignment, all related tags should be returned.&lt;br /&gt;
: * When a user request is made, it should return records related to current user only.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
&lt;br /&gt;
: * When user_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When assignment_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When questionnaire_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When an unauthorized user tries to access the #index, the user should be returned to root_page.&lt;br /&gt;
: * When additional invalid param is sent to the method, the functionality should not get impacted.&lt;br /&gt;
: * When there are large number of answer tags, the tags are handled properly.&lt;br /&gt;
&lt;br /&gt;
''create_edit'' : Allow the creation or updating of an answer tag.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: * When a current tag is accessed, the current tag should be updated with new provided values.&lt;br /&gt;
: * When a current tag is accessed by a student, the current tag should not be updated with new values.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no mapping is found related to any tag_prompt_deployment for that tag (foreign key constraint), an empty list of tags prompts should be returned.&lt;br /&gt;
&lt;br /&gt;
===Tag Prompt Deployment Controller===&lt;br /&gt;
The controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/models/tag_prompt_deployment.rb] is used by an instructor to view the tagging summary of the users that completed the answer tagging. It also indicates that comments are to be tagged for the characteristic specified by the tag prompt.&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''tag_prompt'' : Tests that the tag prompt associated with the provided tag_prompt_id is correctly returned by the tag_dep.tag_prompt method.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When given a valid tag_prompt_id, it should return the associated tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
: * When given an invalid tag_prompt_id, it should not return a tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
''get_number_of_taggable_answers'' : Calculates total taggable answers assigned for a user who participated in ``tag review assignment.''&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When user_id is nil, it should return an error message.&lt;br /&gt;
: * When answer_length_threshold is null, it should return a count of tangible answers.&lt;br /&gt;
: * When answer_length_threshold is not null, it should return a count of taggable answers less than answers_one.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When there are no responses, it should return zero as the count of taggable answers.&lt;br /&gt;
: * When questions are empty, it should return count of taggable answers as zero.&lt;br /&gt;
&lt;br /&gt;
''assignment_tagging_progress'' : Accesses the percentage progress of answer tagging.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do not vary by round, it should calculate the tagging progress for each user.&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do vary by round, it should calculate the tagging progress for each user considering all tagged items.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no questions are found, it should return an empty list.&lt;br /&gt;
: * When there are no teams or questions, it should return an empty list.&lt;br /&gt;
&lt;br /&gt;
==Testing Details==&lt;br /&gt;
====Demo Videos====&lt;br /&gt;
put demo video here&lt;br /&gt;
&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb] and [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb].&lt;br /&gt;
&lt;br /&gt;
=====How to See Test Coverage=====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
1. Modify base files&lt;br /&gt;
   a. correct several method names (ex: not named after a verb (assignment_tagging_progress))&lt;br /&gt;
   b. make tag_prompt_deployment.rb more readable and better commented&lt;br /&gt;
   c. Break some methods down into smaller ones for better functionality (assignment_tagging_progress)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
# [https://github.com/CSC517-Project3/expertiza Project Repository]&lt;br /&gt;
# [https://github.com/orgs/CSC517-Project3/projects/1/views/1 Github Project Board]&lt;br /&gt;
# [https://github.com/expertiza/expertiza/pull/2775 Pull Request]&lt;br /&gt;
# [https://www.theodinproject.com/lessons/ruby-introduction-to-rspec RSpec]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=161551</id>
		<title>CSC/ECE 517 Spring 2025 - E2505. Testing Answer Tagging</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Spring_2025_-_E2505._Testing_Answer_Tagging&amp;diff=161551"/>
		<updated>2025-03-22T23:15:57Z</updated>

		<summary type="html">&lt;p&gt;Vdeo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==E2413. Testing - Answer Tagging==&lt;br /&gt;
&lt;br /&gt;
This wiki page is for the description of changes made in Spring 2025, CSC/ECE 517 for the E2505 Testing - Testing Answer Tagging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Expertiza==&lt;br /&gt;
In accordance with the [http://rubyonrails.org/ Ruby on Rails] framework, [http://expertiza.ncsu.edu/ Expertiza] is an open source software project (OSS) led by [https://www.csc.ncsu.edu/people/efg Dr. Edward Gehringer]. Through this platform, the instructor can add and edit assignments that students are able to view and contribute to. There are various filtering methods that streamline this process. There is also the ability for students to peer review other students to give contributing feedback.&lt;br /&gt;
&lt;br /&gt;
==Objective==&lt;br /&gt;
Our objective is to test two files which are part of this process. We are testing a controller for answer tags DESCRIBE ANSWER TAGS HERE EDIT ME. As well as a model for tag prompt deployment which interfaces with this answer tags controller which has methods that return various information about a students progress in tagging answers.&lt;br /&gt;
&lt;br /&gt;
==Controller and Spec Files==&lt;br /&gt;
Answer Tags&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/answer_tags_controller.rb answer_tags_controller.rb] with initial coverage of 0%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/controllers/answer_tags_controller_spec.rb answer_tags_controller_spec.rb]&lt;br /&gt;
&lt;br /&gt;
Tag Prompt Deployment&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/app/controllers/tag_prompts_controller.rb tag_prompt_deployment.rb] with initial coverage of 17.65%&lt;br /&gt;
* [https://github.com/CSC517-Project3/expertiza/blob/dev/spec/models/tag_prompt_deployment_spec.rb tag_prompt_deployment_spec.rb]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Testing Implementation==&lt;br /&gt;
===Answer Tags Controller===&lt;br /&gt;
This controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/controllers/answer_tags_controller.rb] creates/edits answer tags and tracks the number of tags a student has completed overall per assignment or questionnaire. The controller filters based on assignment_id, questionnaire_id and user_id to present appropriate records. The controllers' output is a JSON-formatted collection of response tags. &lt;br /&gt;
&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''action_allowed?'' : Determines if the user has the permission to see all the tags or create_edit a tag.&lt;br /&gt;
&lt;br /&gt;
: Use Cases: &lt;br /&gt;
&lt;br /&gt;
: * When it is a student session, access to index should be allowed.&lt;br /&gt;
: * When it is a student session, access to create_edit should be allowed.&lt;br /&gt;
: * When it is a student session, access to destroy should not be allowed.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
&lt;br /&gt;
: * When the session is undefined, access to index should be inaccessible.&lt;br /&gt;
: * When the session is undefined, access to create_edit should be inaccessible.&lt;br /&gt;
: * When the session is undefined, access to destroy should be inaccessible.&lt;br /&gt;
&lt;br /&gt;
''index'' : Returns all the tag prompt deployments in JSON format&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: - For any authenticated user above student acess:&lt;br /&gt;
:   * When anyone above student privilege is authorized&lt;br /&gt;
:   * When there are no tag prompts deployed, a empty list should be displayed.&lt;br /&gt;
:   * When there is 1 tag prompt deployed, 1 should be displayed.&lt;br /&gt;
:   * When there are tag prompts deployed with no associated assignment answer tag, tag prompts should not be displayed.&lt;br /&gt;
:   * When there is an answer tag associated with an user_id, it should be filtered by an user_id.&lt;br /&gt;
:   * When there is an answer tag associated with an assignment_id, it should be filtered by an assignment_id.&lt;br /&gt;
:   * When there is an answer tag associated with a questionnaire_id, it should be filtered by a questionnaire_id.&lt;br /&gt;
:   * When there is an answer tag associated with an user_id, assignment_id, and questionnaire_id, it should be filtered by a user_id, assignment_id, questionnaire_id.&lt;br /&gt;
:   * When there is no answer tag associated with a assignment_id, no tag prompts are returned for a assignment_id with no associated answer tags.&lt;br /&gt;
:   * When there is no answer tag associated with a questionnaire_id, no tag prompts are returned for a questionnaire_id with no associated answer tags.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
&lt;br /&gt;
: * When user_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When assignment_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
: * When questionnaire_id is undefined, an empty list of tags prompts should be returned.&lt;br /&gt;
&lt;br /&gt;
''create_edit'' : Allow the creation or updating of an answer tag.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
&lt;br /&gt;
: * When a current tag is accessed, the current tag should be updated with new provided values.&lt;br /&gt;
: * When a current tag is accessed by a student, the current tag should not be updated with new values.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no mapping is found related to any tag_prompt_deployment for that tag (foreign key constraint), an empty list of tags prompts should be returned.&lt;br /&gt;
&lt;br /&gt;
===Tag Prompt Deployment Controller===&lt;br /&gt;
The controller [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/app/models/tag_prompt_deployment.rb] is used by an instructor to view the tagging summary of the users that completed the answer tagging. It also indicates that comments are to be tagged for the characteristic specified by the tag prompt.&lt;br /&gt;
=====Methods=====&lt;br /&gt;
''tag_prompt'' : Tests that the tag prompt associated with the provided tag_prompt_id is correctly returned by the tag_dep.tag_prompt method.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When given a valid tag_prompt_id, it should return the associated tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases: &lt;br /&gt;
: * When given an invalid tag_prompt_id, it should not return a tag prompt with the deployment.&lt;br /&gt;
&lt;br /&gt;
''get_number_of_taggable_answers'' : Calculates total taggable answers assigned for a user who participated in ``tag review assignment.''&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When user_id is nil, it should return an error message.&lt;br /&gt;
: * When answer_length_threshold is null, it should return a count of tangible answers.&lt;br /&gt;
: * When answer_length_threshold is not null, it should return a count of taggable answers less than answers_one.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When there are no responses, it should return zero as the count of taggable answers.&lt;br /&gt;
: * When questions are empty, it should return count of taggable answers as zero.&lt;br /&gt;
&lt;br /&gt;
''assignment_tagging_progress'' : Accesses the percentage progress of answer tagging.&lt;br /&gt;
&lt;br /&gt;
: Use Cases:&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do not vary by round, it should calculate the tagging progress for each user.&lt;br /&gt;
: * When there is a team, a question, and the assignment's rubrics do vary by round, it should calculate the tagging progress for each user considering all tagged items.&lt;br /&gt;
&lt;br /&gt;
: Edge Cases:&lt;br /&gt;
: * When no questions are found, it should return an empty list.&lt;br /&gt;
: * When there are no teams or questions, it should return an empty list.&lt;br /&gt;
&lt;br /&gt;
==Testing Details==&lt;br /&gt;
====Demo Videos====&lt;br /&gt;
put demo video here&lt;br /&gt;
&lt;br /&gt;
====Using RSpec====&lt;br /&gt;
&lt;br /&gt;
We implemented tests in [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb] and [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb].&lt;br /&gt;
&lt;br /&gt;
=====How to See Test Coverage=====&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/controllers/answer_tags_controller_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
# Run RSpec for [https://github.com/Michael-Anderson-NCSU/expertiza/blob/main/spec/models/tag_prompt_deployment_spec.rb], &amp;lt;code&amp;gt;sudo su&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;yum install lynx&amp;lt;/code&amp;gt;,  then &amp;lt;code&amp;gt;lynx ./coverage/index.html&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Results==&lt;br /&gt;
Both files are 100% covered and additional testing was added to ensure a solid groundwork.&lt;br /&gt;
&lt;br /&gt;
==Future Work==&lt;br /&gt;
1. Modify base files&lt;br /&gt;
   a. correct several method names (ex: not named after a verb (assignment_tagging_progress))&lt;br /&gt;
   b. make tag_prompt_deployment.rb more readable and better commented&lt;br /&gt;
   c. Break some methods down into smaller ones for better functionality (assignment_tagging_progress)&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
# [https://github.com/expertiza/expertiza Expertiza GitHub]&lt;br /&gt;
# [https://github.com/CSC517-Project3/expertiza Project Repository]&lt;br /&gt;
# [https://github.com/orgs/CSC517-Project3/projects/1/views/1 Github Project Board]&lt;br /&gt;
# [https://github.com/expertiza/expertiza/pull/2775 Pull Request]&lt;br /&gt;
# [https://www.theodinproject.com/lessons/ruby-introduction-to-rspec RSpec]&lt;/div&gt;</summary>
		<author><name>Vdeo</name></author>
	</entry>
</feed>