CSC/ECE 517 Spring 2023 - E2345. Reimplement QuestionnairesController and QuestionsController

From Expertiza_Wiki
Jump to navigation Jump to search

Introduction

This page gives a description of the changes made for the questions_controller.rb, questionnaire_controller.rb, question.rb & questionnaire.rb of Expertiza based OSS project.

Problem Statement

What is needed: This project builds on E2321, and the main goal is to get the endpoints of QuestionsController and QuestionnairesController running in reimplementation-backend repository. Detailed goals of the project are as follows:

  1. Improving the clarity and conciseness of code: The code should be written in a clean and concise manner. Methods with identical names that perform different functionalities should be renamed for clarity. Functions or functionality that are not clear should be commented on or removed. Any loops or methods that can be refactored for better performance should be addressed.
  2. Discarding unused functionality: Any unused functionality should be removed from the controllers. This will help to reduce complexity and make the code easier to maintain.
  3. Writing tests for the two controllers: Tests should be written for both the QuestionnairesController and the QuestionsController. The tests should cover at least 80% of the code, and tools like Rubocop and Code Climate should be used to verify code smells.
  4. Reimplement Questions and Questionnaires models: Reimplement the two models to facilitate the endpoints of the respective controllers.
  5. Writing tests for the two models: Tests should be written for both the Questionnaires and the Questions models. The tests should cover at least 80% of the code, and tools like Rubocop and Code Climate should be used to verify code smells.

General Design Goals

  • Ensure all prior/expected functionality is working correctly, and if not, make any repairs or changes necessary.
  • Ensure that the each of the models and controllers have loose coupling and tight cohesion.
  • DRY out prior implementation's controller and model methods which have functionality that already exists within the expertiza system.
  • Ensure all present test cases still work properly after making the above changes and create additional test cases.

Implementation Plan

To get the questions and questionnaires module running in the reimplementation-back-end repository, we plan to follow these steps:
1. Reimplement basic version of question.rb and questionnaire.rb such that it facilitates the controllers' CRUD operations.

  • Add associations to user.rb, role.rb, assignment.rb only.
  • Implement only the functions that depend on the above classes.

2. Write comprehensive test cases for both models using RSpec.
3. Reimplement questions_controller.rb and questionnaires_controller.rb to incorporate the feedback received in E2321. The feedback is as follows:

  • Optimize the Create method in questionnaires_controller.rb such that individual fields does not need to be set and validated.
  • Implement an endpoint to delete all questions associated with a questionnaire.
  • Add a validation to allow deletion of questionnaire only if all questions that belongs to it are deleted first.

4. Write comprehensive test cases for both controllers using RSpec.

Relevant Links

Contributors

This feature was created as part of Dr. Edward Gehringer's "CSC/ECE 517: Object-Oriented Design and Development" class, Spring 2023. The contributors were: Vineet Vimal Chheda, Rohan Jigarbhai Shah, and Aditya Srivastava. Our project mentor was Ankur Mundra (amundra@ncsu.edu)