CSC/ECE 517 Fall 2022 - E2275. Further refactoring and improvement of student quizzes controller

From Expertiza_Wiki
Revision as of 22:06, 12 November 2022 by Pshah9 (talk | contribs)
Jump to navigation Jump to search

Expertiza Overview

Ruby on Rails was used to create Expertiza, a multifunctional online application for instructors and students. Instructors using Expertiza have the ability to design their own teams, classes, assignments, quizzes, and much more. However, students are also permitted to work in groups, take tests, and do tasks. Additionally, Expertiza enables students to share peer reviews, allowing them to collaborate to enhance others' learning opportunities. It is an open-source program, and Expertiza is in Github repository Expertiza.

Problem Statement

Background

The student_quizzes_controller consists of methods involved in creating, scoring & recording responses of the quizzes taken by reviewers or students of the other teams with the same assignment. This controller has some issues that violate essential Rails design principles such as DRY principle. There are few methods in this controller that should have been in model classes. Some methods share code, which creates code repetition. Some method comments need to be rewritten.

Resources

Resource 1 :- https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Spring_2016/Refactor_different_question_types_from_quiz_feature
Resource 2 :- https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2014/oss_E1460_aua
Resource 3 :- https://expertiza.csc.ncsu.edu/index.php/CSC/ECE_517_Fall_2022_-_E2255._Refactor_student_quizzes_controller.rb

Required Changes

This project builds on E2225, and should begin with the refactoring done by that project. That project focused on simplifying the methods instudent_quizzes controller, while this project looks at making the code more understandable and transparent.

  • Method ‘calculate_score’ was moved to the helper completely. Although, the expectation is to retain the redirection logic in the controller and move the business logic to the helper function.
  • Method ‘review_questions’ contains the logic for quiz questionnaire. It makes more sense for it to be moved to the quiz_questionnaire controller instead.
  • Method ‘calculate_score’ contains logic that is similar to the compute_weighted_score method in the quiz_questionnaire.rb. Refactor the logic of the method to leverage the existing implementation and eliminate duplicate code.
  • Utilize the logic in method ‘validate_question’ from the quiz_questionnaire.rb in the calculate_score method instead of the multiple if else statements.

Because this is simply a refactoring project, no functionalities should change. Therefore, existing tests should still pass after these changes have been completed. To test this controller, create a new rspec file for student_quizzes_controller.rb and run the following commands to verify your changes do not break any core functions.
rspec spec/controllers/student_quizzes_controller_spec.rb
Many of these proposed changes require moving the function somewhere else, so some tests may break and require being moved or targeting a different file. Additionally, this file has very little coverage, so manual verification may be required.

Prior Work

The prior work which is the basis for this topic is linked here is linked here. This work was done in Fall of 2020, and as previously mentioned, achieved much of the desired functionality for this task. This prior work will be referenced several times within this documentation, as it has a more comprehensive explanation of the underlying design principles behind the views, controller, model, algorithm, and RSpec tests implemented. These details will only be briefly summarized here.

As previously noted, this prior implementation was rejected due to DRY violations, and so correcting these violations--and explaining how those corrections were done--will be the major focus of this project documentation.