CSC/ECE 517 Fall 2017/E1749 questionnaire controller.rb refactor

From Expertiza_Wiki
Revision as of 23:46, 27 October 2017 by Dbhanda (talk | contribs)
Jump to navigation Jump to search

Expertixa Background

Expertiza is a website that is used and developed by NCSU students and faculty. Coded using Ruby on Rails the source code is readily available on Github -> https://github.com/expertiza/expertiza. The website is used by students for organizing teams, signing up for topics, reviewing other teams and another bunch of tasks. The faculty uses this website to set new tasks, add new questions and a few other tasks.

Team Members

  • Shreyas Zagade
  • Mohit Satarkar
  • Darshan Bhandari

Setting Up The Working Environment

One of several ways to set up the environment and the one we adopted is:-

• cd expertiza • bash ./setup.sh • bundle install • rake db:migrate

  • For logging in as an instructor:-

Username: instructor6 Password: password

Files involved and Issues

  • 1) questionnaire_controller.rb
  • 2) questionnaire_controller_spec.rb

• questionnaires_controller.rb is a fairly complex file. • It contains a lot of methods that are long and hard to understand, these methods need to be broken down into simpler and more specific methods that

       are easier to read/understand. 

• Also, the few instances of code duplication that exist should be removed.

Tasks assigned

• Complete pending tests in questionnaires_controller_spec.rb, and write integration tests for newly-created methods. Please finish one set of pending

       <nowiki>Insert non-formatted text here</nowiki>tests first before refactoring corresponding methods.

• Refactor create method o Write failing tests first o Split into several simpler methods and assign reasonable names o Extract duplicated code into separate methods • Refactor update_quiz, save_choices method o Write failing tests first. o Use polymorphism to replace the long switch statements  Move if conditions to corresponding subclasses (eg. MultipleChoiceCheckbox.rb, MultipleChoiceRadio.rb) with same method name  Replace the conditional with the relevant method calls  Remove duplicated code • Use find_by instead of dynamic method o Write failing tests first o L68, L385, L386, L559, L560

Tasks Completed

1) Completed test cases for create

When test case was pending


After writing test case


2) Completed test cases for update_quiz

When test case was pending



After writing test case