CSC/ECE 517 Fall 2021 - E2117. Refactor questionaires controller.rb

From Expertiza_Wiki
Jump to navigation Jump to search

Introduction

About Expertiza

Expertiza is an open source project developed using a Ruby on Rails framework. In Expertiza, an instructor can create, delete or edit new and existing assignments and also create topics for the students to sign up for or assign them to particular groups or individual students. A student can create teams to work on projects and assignments, and also peer review other's work. The website allows submission of various file type and also URL's.

About questionnaire_controller.rb

Questionnaire is the superclass for all kinds of [1] and rubrics—rubrics for evaluating submissions and teammate contributions, and taking quizzes and surveys. All of these are subclasses of Questionnaire. questionnaires_controller.rb is charged with creating, displaying, and managing Questionnaires. Since it is used so widely, malfunctions could cause bugs in many parts of the system; hence it is especially important that the code be clear.

Issues to be addressed

  • Investigate the need and usage of the method create_questionnaire
  • Refactor the create method into different methods with self-descriptive names for easier understanding
  • The display_type attribute that was being set in the create method is never actually being used and is instead being overwritten by a post_initialization method on the types of objects being created.
  • Investigate the usage of checks for whether a questionnaire is QuizQuestionnaire
  • Replace hard-coded rubric criteria scoring
  • Investigate usage of questionnaire_id parameter
  • Bad if statements
  • Refactor save_all_questions method - Cognitive Complexity and Assignment Branch Condition exceed allowed limit.
  • Refactor copy method - Assignment Branch Condition is too high.

Changes made

  • In none of the files was the create_questionaire method being called so it was deleted.
  • Removed the display_type attribute and added a display_type method that pulls the correct display_type string from the subclass that is being utilized.
  • Removed the Rubric class as it wasn't being used as far as I could tell. This will need to be verified by running a query on the production database.
  • All the other issues couldn't be addressed due to the scope of the display_type attribute to method change suggested by the instructor and the conversion from using a type table to subclasses also suggested by the instructor ballooning the scope of the project to the point that the other changes went out of scope.

Future Work

  • The Questionnaire table still has the display_type attribute and will need to be removed after an exploration of the data has been taken and verified that all display_types are represented by subclasses available.

Team Members

  • Isha Gupta
  • John Marsden
  • Sai Harsha Nadendla