CSC/ECE 517 Fall 2017/E1749 questionnaire controller.rb refactor: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 55: Line 55:
    
    
:After writing test case
:After writing test case
  [[File:create-after.png]]
  [[File:create-after.png] upright=0.75]


2) Completed test cases for update_quiz <br>
2) Completed test cases for update_quiz <br>

Revision as of 00:30, 28 October 2017

About

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 i.e. Instructors and TAs use 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:-
Ubuntu-Expertiza image (.OVA) [Recommended]

This is the link for the image. (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing)
And you can install VirtualBox (free) and import this image into VirtualBox.

Some machine may require you to enable virtualization and then run the following commands.
• cd expertiza
• bash ./setup.sh
• bundle install
• rake db:migrate

  • For logging in as an instructor:-
Username: instructor6
Password: password

Files involved and Issues in them

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

1) Complete pending tests in questionnaires_controller_spec.rb, and write integration tests for newly-created methods. Please finish one set of pending tests first before refactoring corresponding methods.
2) 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

3) 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

4) 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
[[File:create-after.png] upright=0.75]

2) Completed test cases for update_quiz

When test case was pending



After writing test case