CSC/ECE 517 Spring 2021 - E2101. Refactor questionnaires controller.rb

From Expertiza_Wiki
Revision as of 02:13, 20 March 2021 by Jwhostet (talk | contribs)
Jump to navigation Jump to search

Introduction

There are various types of questionnaires that a user can create in Expertiza. These questionnaires assist in evaluating submissions and teammate contributions.

Problem Statement

Questionnaire is a superclass to many different types of questionnaires offered in Expertiza. The Questionnaire controller is responsible for creating, displaying and managing these items. Therefore, due to the importance of this controller, refactoring it was of interest to help improve the readability of its features.

  • Replaced literal values with defined constants to aid in the understanding of code behavior.
  • Investigated whether the method create_questionnaire is used.
  • Fixed the methods that have a questionnaire_id as a parameter, as it is not needed, since those methods should be contained within the model class anyways.
  • Removed one of three checks for QuizQuestionnaire.
  • Corrected the dropdown's default alternatives to reflect the questionnaire's min and max question score.
  • Updated the dropdown's RSpec test to reflect the change in behavior.
  • Discovered more software faults.
  • Moved three of four private methods from the controller to the model.

Solution