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

From Expertiza_Wiki
Jump to navigation Jump to search
(Blanked the page)
 
(39 intermediate revisions by the same user not shown)
Line 1: Line 1:
== 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:-'' <br>
'''Ubuntu-Expertiza image (.OVA) [Recommended]''' <br>
:This is the link for the image. (https://drive.google.com/a/ncsu.edu/file/d/0B2vDvVjH76uEUmNKVncxRUhUVVE/view?usp=sharing) <br>
:And you can install VirtualBox (free) and import this image into VirtualBox. <br>
'''Some machine may require you to enable virtualization and then run the following commands.'''<br>
• cd expertiza <br>
• bash ./setup.sh <br>
• bundle install <br>
• rake db:migrate <br>
*For logging in as an instructor:- <br>
:Username: instructor6 <br>
:Password: password <br>
== Files involved and Issues in them==
1) questionnaire_controller.rb <br>
2) questionnaire_controller_spec.rb
• questionnaires_controller.rb is a fairly complex file. <br>
• 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. <br>
• 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. <br>
2) Refactor create method <br>
:o Write failing tests first <br>
:o Split into several simpler methods and assign reasonable names <br>
:o Extract duplicated code into separate methods <br>
3) Refactor update_quiz, save_choices method <br>
:o Write failing tests first. <br>
:o Use polymorphism to replace the long switch statements <br>
:: Move if conditions to corresponding subclasses (eg. MultipleChoiceCheckbox.rb, MultipleChoiceRadio.rb) with same method name <br>
:: Replace the conditional with the relevant method calls <br>
:: Remove duplicated code <br>
4) Use find_by instead of dynamic method <br>
:o Write failing tests first <br>
:o L68, L385, L386, L559, L560 <br>
==  Tasks Completed  ==
1) Completed test cases for create <br>
:When test case was pending
[[File:Create-before.PNG]]
 
:After writing test case
[[Image:create-after.png|150px] ]
2) Completed test cases for update_quiz <br>
:When test case was pending
:After writing test case

Latest revision as of 02:16, 28 October 2017