CSC/ECE 517 Spring 2022 - E2215: Refactor student quizzes controller: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 11: Line 11:


==Modifications made to the existing code==
==Modifications made to the existing code==
'''1. Modification - ''' Add comments for custom method in this controller explaining the purpose. <br>
'''1. Modification - ''' Added comments for custom methods in this controller explaining the purpose. <br>
'''2. Modification - ''' Line 29  - .first has been changed to .last to count the score of the most recent attempt of the quiz. <br>
'''2. Modification - ''' Line 29  - .first has been changed to .last to count the score of the most recent attempt of the quiz. <br>
'''3. Modification - ''' Change the variables like @map on line 28 and use names which are intuitive for the purpose it serves <br>
'''3. Modification - ''' Line 33  - @map has been renamed to @quiz_response_map to more accurately describe its function. <br>
'''4. Modification - ''' Line 34  - @participant has been changed to @quiz_taker to more accurately describe its function. <br>
'''4. Modification - ''' Line 34  - @participant has been changed to @quiz_taker to more accurately describe its function. <br>
'''5. Modification - ''' Line 39  - The method comment of self.take_quiz has been updated to describe its function <br>
'''5. Modification - ''' Line 39  - The method comment of self.take_quiz has been updated to describe its function <br>

Revision as of 06:15, 21 March 2022

About Expertiza

Expertiza is a multi-purpose web application built using Ruby on Rails for Students and Instructors. Instructors enrolled in Expertiza can create and customize classes, teams, assignments, quizzes, and many more. On the other hand, Students are also allowed to form teams, attempt quizzes, and complete assignments. Apart from that, Expertiza also allows students to provide peer reviews enabling them to work together to improve others' learning experiences. It is an open-source application and its Github repository is Expertiza.

E2215. Refactoring student_quizzes_controller.rb in Expertiza

This page is a description of Expertiza OSS project E2215, which is refactoring the student_quizzes_controller.rb file.

Controller Description

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 needs to be rewritten.

Files Modified

1. student_quizzes_controller.rb
2. finished_quiz.html
3. student_quizzes_helper.rb

Modifications made to the existing code

1. Modification - Added comments for custom methods in this controller explaining the purpose.
2. Modification - Line 29 - .first has been changed to .last to count the score of the most recent attempt of the quiz.
3. Modification - Line 33 - @map has been renamed to @quiz_response_map to more accurately describe its function.
4. Modification - Line 34 - @participant has been changed to @quiz_taker to more accurately describe its function.
5. Modification - Line 39 - The method comment of self.take_quiz has been updated to describe its function
6. Modification - Controller Method calculate_score has been split into three separate functions and has been moved to student_quizzes_helper.rb.
7. Modification - Line 60 - A method comment has been added for record_response to describe its function
8. Modification - -graded? has been removed as it is no longer necessary.
9. Modification - Line 72 - The Flash message has been updated.
10. Modification - Line 77 - The method comment for review_questions has been updated.

Tests on the Controller Methods

Video on changes made