CSC/ECE 517 Fall 2022 - E2277. Further Refactoring questionnaires controller.rb: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 72: Line 72:
To be carried out.
To be carried out.


==Design Pattern==
==SOLID Principle==


A design pattern is a general repeatable solution to a commonly occurring problem in software design. It is a description or template for how to solve a problem that can be used in many different situations.
SOLID is a set of rules that guide us on how to achieve that in object-oriented programming. Using SOLID guidelines you can avoid bad design in your code and give a well-structured architecture to your design. Bad design leads to an inflexible and brittle codebase, a simple and small change can result in bugs with bad design.


During the process of refactoring methods as well as method names,'''Strategy Pattern''' was used in the implementation. The Strategy pattern is most useful when you want to provide multiple ways of processing a request, without hard-coding knowledge about those different methods into the object that handles the request.
We implemented the single responsibility principle to divide the questionnaires_controller into questionnaires and questions controller thus ensuring that each controller does only one job.




Line 83: Line 83:
* [https://github.com/Ashwinshankar98/expertiza GitHub]
* [https://github.com/Ashwinshankar98/expertiza GitHub]


* [https://www.rubyguides.com/2015/12/ruby-refactoring/ Introduction to Refractoring in Ruby]
* [https://www.rubyguides.com/2015/12/ruby-refactoring/ Introduction to Refactoring in Ruby]


* [http://rspec.info/documentation/3.8/rspec-core/ Rspec Documentation]
* [http://rspec.info/documentation/3.8/rspec-core/ Rspec Documentation]

Revision as of 20:55, 16 November 2022

Introduction

This page gives a description of the changes made for the questionnaires_controller.rb of the Expertiza-based OSS project.

Expertiza Background

Expertiza is a web application where students can submit and peer-review learning objects (articles, codes, websites, etc). Instructors add and grade the assignments submitted by students to Expertiza. Students can be assigned in teams based on their selection of the topics. It has functionalities such as peer reviews in which students can provide feedback on others' work which helps peer in better developing the project. It is supported by the National Science Foundation.

Problem Statement

What is needed: This project builds on E2257. That project focused on simplifying the methods in questionnaires_controller, while this project's objective is to separate the current controller into two different controllers - questionnaires_controller and questions_controller. Further cleaning of code is also planned along with this.

  • Make use of temporary variables instead of instance variables wherever possible to narrow down their scope.
  • question.rb contains a large number of constants. Make clear comments on their usage else remove it.
  • Since a controller should only create objects of one type the questions_controller could be introduced to create and edit questions moving the logic of dealing with individual questions into a separate controller, and improving the separation of responsibility.

Implementation

Flowchart

The following process is carried out to complete the project-

Refactoring

Refactoring method

Testing

RSpec Testing

RSpec testing was carried out for the methods that had been refactored. Given below are the tests which are written for the functions that are modified:

describe 'My Test Cases' do
  before(:each) do
    create(:instructor)
    create(:role_of_student)
    login_as("instructor6")
    visit '/tree_display/list'
    click_link 'View reports'
    expect(page).to have_current_path('/reports/response_report')
    click_link 'View'
  end

  it "can display review metrics", js: true do
    expect(page).to have_content('Metrics')
  end

  it "can display review grades of each round", js: true do
    expect(page).to have_content('Score awarded')
  end

  it "can display review summary", js: true do
    expect(page).to have_content('Reviews done')
  end

  it "can display review summary", js: true do
    expect(page).to have_content('Reviewer')
  end

  it "can display review summary", js: true do
    expect(page).to have_content('Team reviewed')
  end
end


Manual Testing

To be carried out.

SOLID Principle

SOLID is a set of rules that guide us on how to achieve that in object-oriented programming. Using SOLID guidelines you can avoid bad design in your code and give a well-structured architecture to your design. Bad design leads to an inflexible and brittle codebase, a simple and small change can result in bugs with bad design.

We implemented the single responsibility principle to divide the questionnaires_controller into questionnaires and questions controller thus ensuring that each controller does only one job.


References

Team Members