User:Bkurra: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
CSC/ECE 517 Spring 2024 - E2415: Reimplementation of responses_controller.rb (Design Document)


==Expertiza==
==Expertiza==
Line 28: Line 27:
By achieving these design objectives, the project seeks to create a `responses_controller.rb` that is resilient, efficient, and user-friendly for both the current development team and future system maintainers.
By achieving these design objectives, the project seeks to create a `responses_controller.rb` that is resilient, efficient, and user-friendly for both the current development team and future system maintainers.


== Design Pattern ==
== Design Pattern ==  


During the code refactoring process, we conscientiously followed various design patterns to enhance the overall structure.
Throughout the code rewriting effort, we meticulously adhered to certain design patterns to improve the overall architecture.
When refactoring the Response model and associated controller and helper methods in the application, several key design patterns and principles were followed to ensure improved code quality, maintainability, and scalability. Here are the primary patterns and principles that were considered:
During the redesign of the Response model and its corresponding controller and helper methods within the application, several fundamental design patterns and concepts were adhered to in order to enhance code quality, maintainability, and scalability. The following are the principal patterns and principles that were taken into account:


=== Single Responsibility Principle (SRP) ===
=== Single Responsibility Principle (SRP) ===
This principle was applied to break down complex methods into smaller, more focused functions that handle a specific part of the process
This technique was utilized to decompose intricate methods into smaller, more targeted functions that manage a specific aspect of the process.


*In the Response Model:
In the Response Model, Validate_params was subdivided into several smaller methods, each responsible for a distinct aspect of the validation process. This enables each method to oversee a specific facet of the validation, hence enhancing the maintainability and modifiability of the code.
Validate_params was broken down into multiple smaller methods, each handling a specific part of the validation process. This allows each method to manage one aspect of the validation, making the code easier to maintain and modify.
The establishment and administration of relationships and fundamental properties were distinctly articulated, ensuring that the Response class remains unencumbered by logic unrelated to its specific attributes or relationships.
Creation and management of relationships and basic attributes were clearly defined, ensuring that the Response class isn't overloaded with logic that doesn't pertain to its direct attributes or relationships.


*In the ResponsesController:
In the ResponsesController, the methods such as create, update, and show are designed solely to manage HTTP requests while delegating business logic to the model or helper methods. This maintains the controller actions in a clean and focused manner for routing and fundamental request management.
The controller methods like create, update, show, etc., were defined to handle only HTTP requests and delegate business logic to the model or helper methods. This keeps the controller actions clean and focused on routing and basic request handling.


*In the ResponseHelper:
In the ResponseHelper, methods like create_answers and update_answers exemplify the principle that each method is designated for either the creation or the updating of answers, but not both. This adheres to SRP by partitioning duties into more manageable, distinct operations.
Methods such as create_answers and update_answers are good examples where each method is tasked with either creating or updating answers but not both. This follows SRP by dividing the responsibilities into more manageable, discrete operations.


===Factory Method===
===Factory Method===
The Factory Method pattern can be seen implicitly where object creation processes are encapsulated within the model or helper methods, such as creating a new ResponseMap or generating new Answer objects. This ensures that object creation is modular and separated from the main application logic.
The Factory Method design is implicitly evident when object generation procedures are encapsulated within the model or auxiliary methods, such as instantiating a new ResponseMap or generating new Answer objects. This guarantees that object instantiation is modular and distinct from the primary application logic.
===Strategy Pattern===
===Strategy Pattern===
By defining a family of algorithms (in this case, validation rules for different actions like create or update), encapsulating each one, and making them interchangeable, the strategy pattern lets the algorithm vary independently from the clients that use it. For instance, separating the validation conditions for creating and updating responses allows for flexible swapping and extension of validation logic without modifying the controller or model directly.
The strategy design enables the independent variation of algorithms by establishing a family of encapsulated algorithms, such as validation criteria for activities like creation or updating, and allowing them to be interchangeable for the clients that utilize them. Separating the validation criteria for response creation and updating facilitates the flexible interchange and enhancement of validation logic without necessitating direct alterations to the controller or model.
===Observer Pattern===
Observer Pattern
Used typically in scenarios where changes to a particular object need to notify other dependent objects automatically. In the context of this application, this could relate to notifying instructors or peers upon the submission or update of responses, handled through the helper methods for sending emails.
Typically employed in situations where modifications to a certain object must automatically inform other dependant objects. Within the framework of this program, this may pertain to alerting instructors or peers following the submission or modification of responses, managed via the auxiliary ways for dispatching emails.
===Template Method===
===Template Method===
This pattern can be used in defining the skeleton of an operation in a method, deferring some steps to subclasses or other methods. It's seen in how validate_params uses a general structure for validation but defers the specifics to methods like validate_create_conditions and validate_update_conditions.
This pattern can be employed to delineate the framework of an operation within a method, postponing certain phases to subclasses or other methods. The validation process in validate_params employs a generic framework while delegating specific details to methods such as validate_create_conditions and validate_update_conditions.




By integrating these design patterns and principles, the refactoring aims to achieve a more robust, maintainable, and scalable system. This approach not only addresses current complexities but also lays a foundation for easier future enhancements and modifications.
The refactoring seeks to establish a more resilient, manageable, and scalable system through the integration of various design patterns and concepts. This method not only resolves existing complexities but also establishes a basis for more straightforward future improvements and alterations.


== Class Diagram ==
== Class Diagram ==
Line 65: Line 61:




== Solutions/Details of Changes Made==
== Solutions/Details of Changes Made== 
=== Response Model ===
=== Response Model ===
Methods within the response model were refactored or introduced, including:
Methods in the response model were either refactored or newly added, including: 
==== set_content ====
==== set_content ====
Redesigned to gather and prepare the required data for response objects, optimizing the interaction with associated models
 Reengineered to collect and organize the necessary data for response objects, enhancing the interaction with related models.
==== validate_params ====
==== validate_params ====
This is the original method that was 46 lines long:
This is the original approach including 46 lines.


[[File:Validate parameters before.png|900px]]
[[File:Validate parameters before.png|900px]]


===This method was significantly refactored to improve parameter validation. It was split into multiple smaller, focused methods, each dedicated to handling a specific aspect of the validation process. Each new method does one thing only, which makes them easier to understand and maintain.===
==This method underwent substantial refactoring to enhance parameter validation. It was divided into several smaller, targeted procedures, each assigned to address a certain facet of the validation process. Each new method performs a singular function, hence enhancing comprehension and maintainability.==
* assign_map_id_from_params: Sets the map_id for the response based on the provided parameters, ensuring the correct map ID is used for both creating and updating responses.
*Assigns the map_id for the response according to the specified parameters, ensuring the accurate map ID is utilized for both creation and modification of responses.
[[File:Assign map id.png|900px]]
[[File:Assign map id.png|900px]]


*set_and_validate_response_map: Establishes and validates the presence of the response_map based on map_id. It's crucial to ensure that any response being created or updated is linked to a valid response map.This method attempts to find a ResponseMap based on map_id. If it fails to find one, it records an error and halts further validation, signaling an issue early in the process.
*set_and_validate_response_map: Confirms and verifies the existence of the response_map according to map_id. It is essential to verify that any answer being generated or modified is associated with a proper response map.This method seeks to locate a ResponseMap using map_id. If it cannot locate one, it logs an error and ceases further validation, indicating a problem early in the procedure.
[[File:Set and validte response.png|900px]]
[[File:Set and validate response.png|900px]]


*set_response_attributes(params):Assigns additional attributes to the response object from the parameters. This centralizes attribute setting, reducing redundancy and errors.Directly extracts values like round, version_num, additional_comment, and visibility from the parameters and assigns them to the response object.
*set_response_attributes(params): Allocates supplementary attributes to the response object derived from the parameters. This consolidates attribute configuration, minimizing redundancy and errors.Extracts values such as round, version_num, additional_comment, and visibility from the arguments and assigns them to the answer object.
[[File:Set response attributes.png|900px]]
[[File:Set response attributes.png|900px]]


*action_specific_validation(params, action): Directs the validation flow based on whether the action is to create or update a response, organizing the logic clearly and preventing condition sprawl in the main validation method.Calls specific validation methods based on the action type: validate_create_conditions for creation and validate_update_conditions for updates.
*action_specific_validation(params, activity): Orchestrates the validation process contingent upon whether the action pertains to creating or updating a response, systematically structuring the logic to avert condition proliferation in the primary validation procedure.Invokes various validation methods according to the action type: validate_create_conditions for creation and validate_update_conditions for updates.
[[File:Action specific validation.png|900px]]
[[File:Action specific validation.png|900px]]


*validate_create_conditions: Ensures that a new response doesn't duplicate an existing one under the same response map, round, and version number.Searches for an existing response that matches the current map_id, round, and version_num. If such a response exists, it adds a validation error and prevents the creation of a duplicate response.
*validate_create_conditions: Verifies that a new response does not replicate an existing response inside the same response map, round, and version number.Conducts a search for a pre-existing response that corresponds to the current map_id, round, and version_num. If such a response exists, it generates a validation error and inhibits the generation of a duplicate answer.
[[File:Validate create condition.png|900px]]
[[File:Validate create condition.png|900px]]


*validate_update_conditions(params): Ensures that updates to a response are valid, specifically checking that a response isn't already submitted and that its map_id remains unchanged.Checks the submission status and whether there's an attempt to change the map_id. If either condition is violated, it records an error.
validate_update_conditions(params): Verifies the validity of updates to a response, specifically confirming that the response has not been previously sent and that its map_id remains constant.Verifies the submission status and assesses any attempts to modify the map_id. Should either criteria be breached, an error is documented.
[[File:Validate update conditions.png|900px]]
[[File:Validate update conditions.png|900px]]


*validate_submission_status(params): Updates the submission status of the response during the update process, ensuring the attribute is correctly set based on the provided parameters.Extracts and sets the is_submitted status from the parameters, which is crucial for controlling the editability of the response.
validate_submission_status(params): Modifies the submission status of the response during the update procedure, guaranteeing that the attribute is accurately configured according to the supplied parameters.Extracts and establishes the is_submitted state from the parameters, which is essential for regulating the editability of the answer.
[[File:Validate submission status .png|900px]]
[[File:Validate submission status.png|900px]]


==== serialize_response ====
==== serialize_response ====
Improved to efficiently serialize response data for API interactions, enhancing the clarity and usability of data exchanges.
Optimized for the effective serialization of answer data in API contacts, hence boosting the clarity and usefulness of data exchanges.


=== Response Controller ===
=== Response Controller ===
The ResponseController, originally extensive with numerous functions beyond basic CRUD operations, has been streamlined for our API application. In this context, there's no need to manage data variables for view pages, simplifying the handling of request data solely through request methods.To enhance the architecture and efficiency of our application, we've eliminated redundant methods and consolidated functionalities across the model, controller, and helper files. This restructuring was essential for refining the response endpoints specifically tailored for an API application.
The ResponseController, initially comprehensive with several features exceeding simple CRUD operations, has been optimized for our API application. In this scenario, it is unnecessary to manage data variables for view pages, hence streamlining the handling of request data exclusively through request methods.To improve the architecture and efficiency of our program, we have removed unnecessary methods and integrated functionality across the model, controller, and helper files. The restructure was crucial for optimizing the response endpoints specifically designed for an API application.


Before we added Basic CRUD like New, Create, Update, edit, destroy.
Prior to the incorporation of fundamental CRUD operations such as Create, Read, Update, Edit, and Delete.


Removed Methods: Legacy methods like Questionnaire_from_response_map and Questionnaire_from_response were removed following the refactoring of set_content, which now handles its functionalities internally without the need for these methods.
Removed Methods: The legacy methods Questionnaire_from_response_map and Questionnaire_from_response were eliminated with the reworking of set_content, which now internally manages their functionalities.


==== Show_calibration_results_for_student ====
==== Show_calibration_results_for_student ==== =
Before:
Before:


[[File:Show calibration results for student.PNG|900px]]
[[File:Display calibration outcomes for student.PNG|900px]]


The old implementation also made use of database queries in the viewThis will not be possible in the reimplemented Expertiza, and the required data will need to be made available in the JSON response sent by the controller.   
The previous solution also utilized database queries within the displayThe reimplemented Expertiza will not permit this, necessitating that the relevant data be included in the JSON response sent by the controller.   
[[File:DB access in view.PNG|900px]]
[[File:DB access in view.PNG|900px]]
[[File:DB access in view 2.PNG|900px]]
[[File:DB access in view 2.PNG|900 pixels]]


The new show_calibration_results_for_student method retrieves and displays calibration and review responses based on provided map IDs. It fetches responses using these IDs, retrieves associated questions and answers, and returns the data as a formatted JSON object. If a response is not found, it returns an error indicating the missing response. The method handles any exceptions by returning a standard error message, ensuring robust error handling throughout the process.
The new show_calibration_results_for_student method obtains and presents calibration and review replies according to specified map IDs. It retrieves responses utilizing these IDs, acquires corresponding questions and answers, and presents the data as a structured JSON object. In the absence of a response, an error is generated to signify the lack of a response. The method manages all exceptions by providing a standardized error message, hence assuring comprehensive error handling during the operation.
Serves as an API endpoint to fetch detailed response data for a student's calibration and review tasks, providing all necessary details about the questions asked and the answers provided in both contexts
Functions as an API endpoint to retrieve comprehensive response data for a student's calibration and review activities, supplying all pertinent information regarding the questions posed and the answers given in both scenarios.


[[File:Show_calibration_results.png|900px]]
[[File:Show_calibration_results.png|900px]]
Line 124: Line 120:
=== Response Helper ===
=== Response Helper ===


The method create_update_answers(response, answers) was originally handling both the creation and updating of answer records within a single method:
The method create_update_answers(response, answers) initially managed both the generation and modification of answer records within a singular function.


[[File:Create_update_answers_before.png|900px]]
[[File:Create_update_answers_before.png|900px]]


To improve code maintainability and adhere to the Single Responsibility Principle, this method has been divided into two distinct methods:
To enhance code maintainability and comply with the Single Responsibility Principle, this method has been separated into two distinct methods:


==== Create_answers ====
Create_answers ==== ====
This method focuses solely on creating new answer records. It iterates over the answers provided, checking if each answer does not already exist in the database. If the answer does not exist, it creates a new record for that answer. This ensures that each answer is unique and prevents duplication.
This method is exclusively concerned with generating new answer records. It traverses the submitted responses, verifying that each answer is not already present in the database. If the response is absent, it generates a new record for that answer. This guarantees the uniqueness of each response and inhibits redundancy.
[[File:Create_answers_after.png|900px]]
[[File:Create_answers_after.png|900px]]


==== Update_answers ====
====Update_answers ====  
This method is responsible for updating existing answer records. It searches for existing answers in the database based on the response and question identifiers. If an answer is found, it updates the existing record with the new information provided. This method ensures that all modifications to answers are captured accurately and that the database is kept up-to-date.
This technique updates existing response records. It queries the database for existing replies using the response and question identifiers. Upon discovering an answer, it revises the current record with the newly supplied information. This method guarantees the precise recording of all response updates and maintains the database's currency.


[[File:Update_answers_after.png|900px]]
[[File:Update_answers_after.png|900px]]
Line 166: Line 162:
==Team==
==Team==
===== Mentor=====  
===== Mentor=====  
*Ameya Vaichalkar
*Richard Li


=====Members=====  
=====Members=====  
* Jeff Riehle
* Loyda Yusufova
* Maday Moya
* Bhuvan Chandra Kurra
* Shardul Ladekar


==Links==
==Links==

Latest revision as of 01:48, 30 October 2024

Expertiza

The Expertiza project, an open-source initiative based on Ruby on Rails, pursues ongoing enhancement to incorporate contemporary software engineering methodologies. The Responses Controller is designed to aid reviewers in supplying organized data that conforms to an assignment's rubrics, assuring the availability of pertinent questions for each round within the appropriate deadline. It allows a reviewer to assess and grade the rubric questions relevant to the assignment's subjects. Moreover, it guarantees the provision of relevant questions for each assignment round, enabling reviewers to generate and adjust scores and remarks for each rubric question linked to the assignment. Upon the submission of scored questions and comments by reviewers, the Responses Controller sends an email message to the instructor and the members of the reviewed team.

Problem Statement

The ResponseController in Expertiza, a historical system with conventions that predate Rails standards, is too intricate, incorporating functionalities that extend beyond simple CRUD operations and requiring compliance with contemporary Rails nomenclature and design concepts. Critical concerns encompass the direct execution of functions such as sorting reviews and verifying reviewer roles within the controller, indicating a transition towards polymorphism and a more systematic method of code organization. Moreover, the controller's management of email notifications and feedback systems is erratic, highlighting the need for a specialized assistant to optimize communication procedures. The reimplementation initiative must concentrate on streamlining the controller, conforming to Rails principles, and enhancing code readability and maintainability through the judicious allocation of responsibilities.

Design Goal

The redesign of `responses_controller.rb` is driven by several primary aims aimed at enhancing code quality, system performance, and developer engagement. The objectives encompass:

  • Maintainability and Scalability: Guaranteeing the code is comprehensible, modifiable, and extensible. The reimplementation should facilitate future updates and the incorporation of new features.
  • Compliance with Rails Best Practices: Adhering to Rails conventions on nomenclature, architecture, and coding methodologies to guarantee code uniformity and dependability.
  • DRY Principle: "Don't Repeat Yourself" - eliminating unnecessary code and logic to enhance efficiency and reduce errors in the codebase.
  • Single Responsibility Principle: Reorganizing the controller and related models to ensure that each class and method has a singular purpose, hence facilitating enhanced testing and management.
  • Enhanced Testing and Coverage: Augmenting test suites to encompass a broader range of scenarios and edge situations, hence bolstering confidence in the application's stability and performance.
  • Performance Optimization: Recognizing and enhancing sluggish or ineffective segments in the code to guarantee the application operates seamlessly.
  • Eliminate Obsolete Methods: Conduct an audit of the codebase to identify and delete any unneeded ("dead") methods inside the present controller to streamline the code.
  • Diminished Controller Complexity: We have already streamlined the `ResponseController` to concentrate mostly on CRUD activities and have extracted non-essential functionality to suitable models or helpers; now we intend to implement the remaining operations.

By achieving these design objectives, the project seeks to create a `responses_controller.rb` that is resilient, efficient, and user-friendly for both the current development team and future system maintainers.

Design Pattern

Throughout the code rewriting effort, we meticulously adhered to certain design patterns to improve the overall architecture. During the redesign of the Response model and its corresponding controller and helper methods within the application, several fundamental design patterns and concepts were adhered to in order to enhance code quality, maintainability, and scalability. The following are the principal patterns and principles that were taken into account:

Single Responsibility Principle (SRP)

This technique was utilized to decompose intricate methods into smaller, more targeted functions that manage a specific aspect of the process.

In the Response Model, Validate_params was subdivided into several smaller methods, each responsible for a distinct aspect of the validation process. This enables each method to oversee a specific facet of the validation, hence enhancing the maintainability and modifiability of the code. The establishment and administration of relationships and fundamental properties were distinctly articulated, ensuring that the Response class remains unencumbered by logic unrelated to its specific attributes or relationships.

In the ResponsesController, the methods such as create, update, and show are designed solely to manage HTTP requests while delegating business logic to the model or helper methods. This maintains the controller actions in a clean and focused manner for routing and fundamental request management.

In the ResponseHelper, methods like create_answers and update_answers exemplify the principle that each method is designated for either the creation or the updating of answers, but not both. This adheres to SRP by partitioning duties into more manageable, distinct operations.

Factory Method

The Factory Method design is implicitly evident when object generation procedures are encapsulated within the model or auxiliary methods, such as instantiating a new ResponseMap or generating new Answer objects. This guarantees that object instantiation is modular and distinct from the primary application logic.

Strategy Pattern

The strategy design enables the independent variation of algorithms by establishing a family of encapsulated algorithms, such as validation criteria for activities like creation or updating, and allowing them to be interchangeable for the clients that utilize them. Separating the validation criteria for response creation and updating facilitates the flexible interchange and enhancement of validation logic without necessitating direct alterations to the controller or model. Observer Pattern Typically employed in situations where modifications to a certain object must automatically inform other dependant objects. Within the framework of this program, this may pertain to alerting instructors or peers following the submission or modification of responses, managed via the auxiliary ways for dispatching emails.

Template Method

This pattern can be employed to delineate the framework of an operation within a method, postponing certain phases to subclasses or other methods. The validation process in validate_params employs a generic framework while delegating specific details to methods such as validate_create_conditions and validate_update_conditions.


The refactoring seeks to establish a more resilient, manageable, and scalable system through the integration of various design patterns and concepts. This method not only resolves existing complexities but also establishes a basis for more straightforward future improvements and alterations.

Class Diagram

Use cases


== Solutions/Details of Changes Made== 

Response Model

Methods in the response model were either refactored or newly added, including: 

set_content

 Reengineered to collect and organize the necessary data for response objects, enhancing the interaction with related models.

validate_params

This is the original approach including 46 lines.

This method underwent substantial refactoring to enhance parameter validation. It was divided into several smaller, targeted procedures, each assigned to address a certain facet of the validation process. Each new method performs a singular function, hence enhancing comprehension and maintainability.

  • Assigns the map_id for the response according to the specified parameters, ensuring the accurate map ID is utilized for both creation and modification of responses.

  • set_and_validate_response_map: Confirms and verifies the existence of the response_map according to map_id. It is essential to verify that any answer being generated or modified is associated with a proper response map.This method seeks to locate a ResponseMap using map_id. If it cannot locate one, it logs an error and ceases further validation, indicating a problem early in the procedure.

File:Set and validate response.png

  • set_response_attributes(params): Allocates supplementary attributes to the response object derived from the parameters. This consolidates attribute configuration, minimizing redundancy and errors.Extracts values such as round, version_num, additional_comment, and visibility from the arguments and assigns them to the answer object.

  • action_specific_validation(params, activity): Orchestrates the validation process contingent upon whether the action pertains to creating or updating a response, systematically structuring the logic to avert condition proliferation in the primary validation procedure.Invokes various validation methods according to the action type: validate_create_conditions for creation and validate_update_conditions for updates.

  • validate_create_conditions: Verifies that a new response does not replicate an existing response inside the same response map, round, and version number.Conducts a search for a pre-existing response that corresponds to the current map_id, round, and version_num. If such a response exists, it generates a validation error and inhibits the generation of a duplicate answer.

validate_update_conditions(params): Verifies the validity of updates to a response, specifically confirming that the response has not been previously sent and that its map_id remains constant.Verifies the submission status and assesses any attempts to modify the map_id. Should either criteria be breached, an error is documented.

validate_submission_status(params): Modifies the submission status of the response during the update procedure, guaranteeing that the attribute is accurately configured according to the supplied parameters.Extracts and establishes the is_submitted state from the parameters, which is essential for regulating the editability of the answer. File:Validate submission status.png

serialize_response

Optimized for the effective serialization of answer data in API contacts, hence boosting the clarity and usefulness of data exchanges.

Response Controller

The ResponseController, initially comprehensive with several features exceeding simple CRUD operations, has been optimized for our API application. In this scenario, it is unnecessary to manage data variables for view pages, hence streamlining the handling of request data exclusively through request methods.To improve the architecture and efficiency of our program, we have removed unnecessary methods and integrated functionality across the model, controller, and helper files. The restructure was crucial for optimizing the response endpoints specifically designed for an API application.

Prior to the incorporation of fundamental CRUD operations such as Create, Read, Update, Edit, and Delete.

Removed Methods: The legacy methods Questionnaire_from_response_map and Questionnaire_from_response were eliminated with the reworking of set_content, which now internally manages their functionalities.

=== Show_calibration_results_for_student ====

Before:

File:Display calibration outcomes for student.PNG

The previous solution also utilized database queries within the display. The reimplemented Expertiza will not permit this, necessitating that the relevant data be included in the JSON response sent by the controller. 900 pixels

The new show_calibration_results_for_student method obtains and presents calibration and review replies according to specified map IDs. It retrieves responses utilizing these IDs, acquires corresponding questions and answers, and presents the data as a structured JSON object. In the absence of a response, an error is generated to signify the lack of a response. The method manages all exceptions by providing a standardized error message, hence assuring comprehensive error handling during the operation. Functions as an API endpoint to retrieve comprehensive response data for a student's calibration and review activities, supplying all pertinent information regarding the questions posed and the answers given in both scenarios.


Response Helper

The method create_update_answers(response, answers) initially managed both the generation and modification of answer records within a singular function.

To enhance code maintainability and comply with the Single Responsibility Principle, this method has been separated into two distinct methods:

Create_answers ==== ==== This method is exclusively concerned with generating new answer records. It traverses the submitted responses, verifying that each answer is not already present in the database. If the response is absent, it generates a new record for that answer. This guarantees the uniqueness of each response and inhibits redundancy.

Update_answers

This technique updates existing response records. It queries the database for existing replies using the response and question identifiers. Upon discovering an answer, it revises the current record with the newly supplied information. This method guarantees the precise recording of all response updates and maintains the database's currency.

Files Modified/Added

List of primary files modified or created includes:

  • responses_controller.rb
  • response_helper.rb
  • response.rb


Test

Validate Parameters

Postman Tests

Separated Answer Creation and Update Logic

Postman Tests

Creation:

Update:

Team

Mentor
  • Richard Li
Members
  • Loyda Yusufova
  • Bhuvan Chandra Kurra

Links

Postman Video Links:

Pull request: https://github.com/expertiza/reimplementation-back-end/pull/92

Model Tests Video: https://youtu.be/7x8x4l3AksE

Controller Tests Video: https://youtu.be/0PV-ycXfyZU

References