CSC/ECE 517 Fall 2022 - E2257: Refactor questionnaires controller.rb
Introduction
In Expertiza, Questionnaire is the superclass for all kinds of questionnaires 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. Because 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 Fixed
- Removed create_questionnaire
- QuizQuestionnaire check
Files Changed
- app/controllers/questionnaires_controller.rb
- spec/controllers/questionnaires_controller_spec.rb
Changes
Fix #1
The create_questionnnaires
method was present but its related functionality had been removed. Some kind of link to it is still present in one of the initial migrations which was populating a database to show values for a drop-down that is no longer in use. Thus ended up removing the function and its corresponding test cases.
Fix #2
Fix #3
There are three checks for whether a questionnaire is a QuizQuestionnaire. Testing the class of an object is always suspect, though in a controller, which has to control a whole hierarchy of objects, it is not necessarily wrong. However, they probably aren’t necessary. 2 of them seem to have been removed already and the only remaining check was in create_questionnaire, thus it got removed while applying Fix #1.
Fix #4
Fix #5
Project Mentor
Edward Gehringer (efg@ncsu.edu)
Team Member
Ashwin Shankar Umasankar (aumasan@ncsu.edu)
Kailash Singaravelu (ksingar2@ncsu.edu)
Pujitha Enamandala (penaman@ncsu.edu)