CSC/ECE 517 Spring 2023 - E2311. Reimplement QuizQuestion and its child classes

From Expertiza_Wiki
Jump to navigation Jump to search

Background

Current State

Currently, in Expertiza there is a model class called QuizQuestion which serves as a superclass of classes MultipleChoiceCheckbox, MultipleChoiceRadio, and TrueFalse.

There are four methods in the QuizQuestion superclass which return HTML strings, depending on the question type:

  • edit -- What to display if an instructor (etc.) is creating or editing a questionnaire (questionnaires_controller.rb)
  • view_question_text -- What to display if an instructor (etc.) is viewing a questionnaire (questionnaires_controller.rb)
  • view_completed_question -- What to display if a student is viewing a filled-out questionnaire (response_controller.rb)
  • complete -- What to display if a student is filling out a questionnaire (response_controller.rb)

Additionally, the inheriting classes contain a method isvalid that is not in QuizQuestion.

Included below is the UML diagram of the design of the QuizQuestion and its child classes in the current state

Our Implementation Project

For this project, we are tasked with redesigning the above UML diagram and reimplementing the five methods (mentioned in the previous section) in the superclass (QuizQuestion). The reimplementation of the methods in the superclass will provide inheritances to the subclasses (MultipleChoiceCheckbox, MultipleChoiceRadio, and TrueFalse), and will use overriding/overloading to avoid type-checking.

Included below is the redesign of the UML diagram of the relationship between QuizQuestion and its child classes. As shown in the diagram, all methods are moved to the parent class. Child classes either inherit purely from the parent class' methods or extend it through overriding/overloading.

Note that the methods reimplemented in the parent class (QuizQuestion) still render HTML components to provide to the front-end (through the response_controller.rb and questionnaires_controller.rb).

Future Direction

In the future, as the Expertiza app is being migrated to the combination of Ruby API and React front-end (instead of legacy Rails), these methods will be modified to use Ruby API, and to handle and return React objects for the front-end.

Team

  • Aileen Jacob (amjacob2)
  • Anh Nguyen (anguyen9)
  • Joe Johnson (jdjohns4)
  • Mentor Jialin Cui (jcui9)

Detailed Description of Changes

Files Modified/Created

isvalid method

  • Reimplemented the method in quiz_question.rb
  • Removed from multiple_choice_radio.rb and true_false.rb
  • Extended in multiple_choice_checkbox.rb
  • Modified quiz_question_spec.rb and multiple_choice_checkbox_spec.rb to include tests for the method.

view_question_text method

  • left as is in quiz_question.rb

Executing Tests

  • To run the test suite written for our project, use the following command: bundle exec rspec spec/requests/model
  • To run individual test files (separated by model that is being tested), use the following command: bundle exec rspec spec/requests/model/test_file_name.rb

Useful Links

Our Github Forked Repo