CSC/ECE 517 Fall 2014/oss E1467 nms

From Expertiza_Wiki
Revision as of 21:36, 27 October 2014 by Sabdul (talk | contribs) (Created page with "=Expertiza - Refactoring SurveyResponsesController= __TOC__ ==Introduction== Expertiza<ref name="expertiza>''Expertiza'' http://wikis.lib.ncsu.edu/index.php/Expertiza</ref> is ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Expertiza - Refactoring SurveyResponsesController

Introduction

Expertiza<ref name="expertiza>Expertiza http://wikis.lib.ncsu.edu/index.php/Expertiza</ref> is an open source web portal for the use of both students and professors. The Expertiza application allows us to create reusable learning objects through peer review. It allows project submission, team creation and the submission of almost any document type, including URLs and wiki pages. Students can access their pending and finished assignments, they can do peer reviews on several topics and projects. It is developed on Ruby on Rails platform. More information on Expertiza can be found here. The source code has been forked and cloned for making modifications to accommodate changes to survey responses controller.

This wiki provides an insight into our contributions to the OSS Expertiza application, focusing on Refactoring the SurveyResponses Controller.

Project Description

This class creates surveys and records the responses which can be viewed. On submitting the responses, the scores and comments are posted.


Classes : SurveyResponsesController.rb
What it does : Creates surveys, submitting surveys, views responses, posts scores and comments.
What has to be changed :

  • Pluralize the class SurveyResponseController to SurveyResponsesController
  • Changing declarations of Arrays and Hashes,removing commented out code
  • Use of routing helpers instead of hardcoded URLs
  • Move active record queries to the model or another class
  • Reducing the number of instance variables per action to one

Modification to Existing Code

Pluralize the SurveyResponseController class to SurveyResponsesController

  • A new survey_responses_controller.rb file is added : As per Ruby on Rails convention, controller names get pluralized while model names are singular. So, the controller name becomes survey_responses_controller instead of survey_response_controller for SurveyResponse modelclass.

Changing declarations of Arrays and Hashes as per Ruby 1.9 standards

  • Modified declarations of Arrays and Hashes

Before Refactoring : survey_responses_controller.rb

#view_responses
  @responses = Array.new
    
#view_responses
  this_response_survey = Hash.new  

After Refactoring :

#view_responses
  @responses = []
    
#view_responses
  this_response_survey = {}

Move active record queries to the model or another class